Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50076

Change Number in cell based on value from 2 sheets columns A

$
0
0
Hi I Have this below code which works good.

IN Sheet "Pagado" the numbers in column A is always sorted ascending
Below code find the last number in sheet "Pagado"(can be blanks between)
So when i press the button it will take the last number in column A and add 1.
It will display the number in Sheet"Masterinvoice" cell M6

I need this code to be extended.
I need it to search in 2 sheets ( "No Pagado" and "Pagado") both in column A
Again in both sheets the numbers in column A will be sorted ascending.
I need it to find the highest number in these 2 sheets column A.
And then display that number + 1 in Sheet "Masterinvoice" cell M6

In this way i will be sure always to find a new invoice number and always the next number.
I need macro because its part of a bigger project with many macroes.

Please have a look

Attached a sample sheet you can look in.

Thanks in advance

Sincerely
Abjac


The working code for do this in one sheet.

Code:

Sub newinvoicenumber()
    Dim LR As Long, NewNum As Long
    LR = Sheets("Pagado").Range("A" & Rows.Count).End(xlUp).Row
    NewNum = Sheets("Pagado").Cells(LR, 1).Value + 1
    Sheets("Masterinvoice").Range("M6").Value = NewNum
End Sub

Attached Files

Viewing all articles
Browse latest Browse all 50076

Trending Articles