I have a spreadsheet that has data that starts in Column H. I'd like to have my macro insert a formula in front of this column and then copy it all the way down to the last row of data. Here is what I have so far, but I keep getting "application-defined or object-defined error."
I've tried declaring a second range, say starting at cell C2 and going to the row count of rng, but I couldn't get that to work either.
Code:
Dim rng As Range
Set rng = ThisWorkbook.Worksheets("Sheet1").Range("H2").CurrentRegion
With rng.Offset(1, -4).Resize(rng.Rows.Count, 1)
.Formula = "=some formula in here"
.Value = .Value 'copy the value and paste it as a value to remove the formula
End With
I've tried declaring a second range, say starting at cell C2 and going to the row count of rng, but I couldn't get that to work either.