Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for pointing me in the right direction Sam!
Neil "Sam Wilson" wrote: Hi, When using a for... next statement you don't have to manually increment your variable. Try these: For count = 0 to 70 step 5 msgbox count count = count + 5 next count For count = 0 to 70 step 5 msgbox count next count You'll see that the first returns 0,10,20,30... rather than 0,5,10... like the second one does. Delete your count = count + 5 statements Sam "neil" wrote: hi, I have a formula that needs to be pasted into every 5th row, only if there is no existing formula in that target row. I have about 30000 rows of data & 10 such spreadsheets. To hasten this task, I wrote this code, but it is missing out pasting the formula on some rows etc... Sub Macro2() Dim Count As Long Range("B5:M5").Copy For Count = 0 To 70 Step 5 If Range("B5").Offset(Count, 0).HasFormula Then Count = Count + 5 Else Range("B5").Offset(Count, 0).PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Count = Count + 5 End If Next Count End Sub TIA Neil |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pasting Same Formula | Excel Programming | |||
copying and pasting a formula | Excel Worksheet Functions | |||
reading a formula and pasting it | Excel Programming | |||
Pasting formula as text | Excel Programming | |||
Pasting formula with defined name | Excel Programming |