Hi everyone,
I have difficulties trying to writing some VBA codes. As what I have attached, I am trying to copy a range of formulas, and paste them into another range of cells.
For example, when excel detects column A with "Apple", I want to copy formulas from M2:Z2 and copy them to M24:M34. The thing is that the range of M24:M34 is more of variable and always changing, it could be M14:M64 the next day. How should I amend the codes to paste the formulas from M2:Z2 to the M columns between "Apple" and "Pear". Sorry if this is confusing.. but please let me know if there is any uncertainty. Thanks
Sub copyFormula()
myrow = 21
Lastrow = Range("A65000").End(xlUp).Row
For i = 21 To Lastrow
Range("A" & myrow).Select
If ActiveCell.Value = "Apple" Then
Range("M2:Z2").Select
Selection.Copy
Range("M24:M34").Select
ActiveSheet.Paste
End If
myrow = myrow + 1
Next I
End sub
Bookmarks