correct syntax for replacing a number with a variable in VBA

geewhysee

New Member
Joined
Jan 7, 2016
Messages
32
I have this macro

Code:
LastRow = Cells(Rows.Count, "E").End(xlUp).Row


Range("F2").FormulaArray = "=IF(C2=""Job complete"",(D2+E2)-SUM(VLOOKUP(B2&"" - Job assigned/passed"",$A$1:[COLOR=#ff0000]$E$62[/COLOR],{4;5},0)),"""")" 'Insert Array
Range("F2").AutoFill Destination:=Range("F2:F" & LastRow), Type:=xlFillDefault

and I want to replace the 62 in $E$62 with LastRow. I know I need to use & and "" in some configuration but rather than trial and error for an hour or two I thought I'd ask here.
 
Last edited:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try...

Code:
Range("F2").FormulaArray = "=IF(C2=""Job complete"",(D2+E2)-SUM(VLOOKUP(B2&"" - Job assigned/passed"",$A$1:$E$" & LastRow & ",{4;5},0)),"""")"
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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