Question Locked

Copy formulae using a macro

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I want to creat a macro to copy a formula (in L2) into certain cells in col L based on what is in Col B, and have tried the following, but the Set curCell statement gives a run-time error 13. I have updated MS Office to the latest patches.
For Counter = 5 To 100
Set curCell = Worksheets("Cases").Cells("B", Counter)
If (curCell.Value) <> "Product" And (curCell.Value) <> "Description" And (curCell.Value) <> "" Then
Range("L2").Select
Selection.Copy
Set curCell = Worksheets("Cases").Cells("L", Counter)
ActiveSheet.Paste
End If
Next Counter

3 replies

by thumbsup2

Try putting the reference to the Counter into the Set command properly.

Set curCell = Worksheets("Cases").Cells("B" + Counter)

by davidcalver

Thanks, but I finally wrote it as follows as the Counter denotes the row
If Worksheets("Cases").Cells(Counter, 2).Value <> "Product" Then
Range("L2").Select
Selection.Copy
Worksheets("Cases").Cells(Counter,12).Activate
ActiveSheet.Paste

This discussion is closed to new replies.