How to put formula in every other row

dee101

Active Member
Joined
Aug 21, 2004
Messages
282
How can I put this, FormulaR1C1 = "=IF(R[1]C<>"""",""Question"","""")" in every other row starting in A1 down to the last thing in column A
Thanks
Excel 2003
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
TRy
Code:
Sub test()
Dim lr As Long, r As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
For r =lr to 1r Step -2
    Range("A" & r).FormulaR1C1 = "=IF(R[1]C<>"""",""Question"","""")"
Next r
End Sub
 
Upvote 0
For r = lr to lr ??

I don't think you have to go backwards:

Code:
Sub test()
Dim lr As Long, r As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
For r = 1 To lr Step 2
    Range("A" & r).FormulaR1C1 = "=IF(R[1]C="""","""",""Question"")"
Next r
End Sub

Note, I shortened the formula a little bit, it will return the same results.
 
Last edited:
Upvote 0
Hi Hotpepper
Thanks for the pickup......7 am obviously doesn't work for me !!
 
Upvote 0
How about a solution that does not use any loops?

Code:
Sub FillFormulaInEveryOtherRow()
  Dim UnusedColumn As Long
  UnusedColumn = Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Column + 1
  Application.ScreenUpdating = False
  Cells(1, UnusedColumn) = "X"
  Cells(1, UnusedColumn).Resize(2).AutoFill Cells(1, UnusedColumn).Resize(Cells(Rows.Count, "A").End(xlUp).Row)
  Columns(UnusedColumn).SpecialCells(xlConstants).Offset(, 1 - UnusedColumn).FormulaR1C1 = "=IF(R[1]C="""","""",""Question"")"
  Columns(UnusedColumn).Delete
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,144
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top