Hi,
Have you considered just specifying the maximum number of rows you're ever likely to need? e.g. SUM(E19:E1000)
Are you saying you already have a VBA variable and it contains the number of rows that you want to use, or that you need to create the variable.
If the former then
Sheet1.Range("J8") = "=Sum(E19:E" & myvariable + 19 & ")"
If the latter and you want the last used row in a column as the variable then
Dim myVariable as Long
myVariable = Range("E" & Rows.Count).End(xlup).Row
Sheet1.Range("J8") = "=Sum(E19:E" & myvariable & ")"
Adjust the sheet1 ref as necessary.
Bookmarks