Im trying to create a VBAformula that will fill excel with a formula. i've got this VBA code
Dim ws As Worksheet
Dim u As Long
Set ws = ActiveSheet
u = 9
Dim used As Range
Set used = ws.UsedRange
Dim lastRow As Integer
lastRow = used.Row + used.Rows.Count - 2
ws.Range("K4:K" & lastRow).FormulaR1C1 = "=(R4C2-R4C" & u & ")/10"
but in excel I get this formula: =($B$4-$I$4)/10
is it possible with this code to get the formula looking like this? =(B4-I4)/10 without the $ symbol?
$signs in the A1 notation. If you want relative addressing, don't use absolute addressing in R1C1 to being with. A relative address in R1C1 has the form ofR[4]C[2], but you will have to correct the numbers because they are relative to where you put the formula.ActiveSheet. There are also better ways to search for a last used row.