Good morning,
Thanks in advance for any help you can give. I have written a code that uses a reference number in b6 on sheet "Y" to count the number of columns on sheet x based on that number and starts the formula 6 rows down. It then pastes a formula in in the proper cell in row six with the variable column.
Here is the code:
Sub testingme4()
Dim myvalue As Double, lastrow As Long
myvalue = Worksheets("x").Cells(6, 2).Value
Worksheets("y").Cells(6, (myvalue) + 21).Cells.FormulaR1C1 = "formula"
End Sub
This works perfectly for me.
However, when I try to get it to paste down the entire row, it gets wonky.
I added this:
Dim lastrow as long
lastrow = Worksheets("y").Cells(Rows.Count, 1).End(xlUp).Row
Which also work and counts the correct number of rows (used 'MsgBox "Last row of data anywhere: " & lastrow & vbCrLf to verify)
The last part is that I need to loop the formula until it hits the last row of the column picked in my first statement.
I tried:
Dim paster as long,
For paster = Worksheets("x").Cells(6, (myvalue) + 21) To lastrow
Cells.FormulaR1C1 = "formula"
Next paster
This keeps giving me a running out of memory error.
Thanks again for any help.
EP