Vba worksheet formula from last row

Trebor8484

Board Regular
Joined
Oct 27, 2018
Messages
69
Office Version
  1. 2013
Platform
  1. Windows
Hi all, I have a worksheet with thousands of rows of data. The code below works and recalculates the formula each time I add more data to the sheet and then converts the formula to values.

Does anyone have a solution where I can apply the formula but only from the last row in column A to avoid having to apply the formula to the whole column each time, due to the amount of rows Excel grinds to a halt now.

dstsht.Range("AZ2:AZ" & dstsht.Cells(Rows.Count, "A").End(xlUp).Row).Value = "" dstsht.Range("AZ2:AZ" & dstsht.Cells(Rows.Count, "A").End(xlUp).Row).Formula = "=IFERROR(VLOOKUP(D2,'YTD Report'!F:S,10,FALSE),IFERROR(VLOOKUP(D2,'New Report'!B:X,23,FALSE),IFERROR(VLOOKUP(MID(D2,2,2),'Calculation Sheet'!A:B,2,FALSE),""UNKNOWN"")))"
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
This will add a calculation to the cell in column AZ that is in the same row as the last populated cell in column A.

VBA Code:
    With dstsht.Range("AZ" & dstsht.Cells(Rows.Count, "A").End(xlUp).Row)
        .NumberFormat = "General"
        .Formula = "=IFERROR(VLOOKUP(D2,'YTD Report'!F:S,10,FALSE),IFERROR(VLOOKUP(D2,'New Report'!B:X,23,FALSE),IFERROR(VLOOKUP(MID(D2,2,2),'Calculation Sheet'!A:B,2,FALSE),""UNKNOWN"")))"
        Application.Calculate
        .Value = .Value
    End With
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,054
Latest member
juliecooper255

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top