Loop function in VBA

tlrobinson512

New Member
Joined
Jun 24, 2014
Messages
21
Good Morning Everyone!

I am in need of what I think is some easy assistance that I just can't figure out. I am new in the world of VBA, but I am attempting to loop this function until it finds the next empty row in column C.

Private Sub Workbook_Open()

Range("C2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]="""","""",RC[-1]+30)"
Range("C3").Select


End Sub

I have a feeling this is an extremely basic and easy task and I am perhaps, overthinking the code?? Any help you can provide would be much appreciated! Thanks in advance!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try,

Code:
Private Sub Workbook_Open()
	Range("C" & Rows.Count).End(xlUp).Offset(1, 0).Select
	ActiveCell.FormulaR1C1 = "=IF(RC[-1]="""","""",RC[-1]+30)"
End Sub
 
Upvote 0
Thanks for the response vds1. I thought the .End(x1Up) was the way to go as well, but when I insert that into the code it still only gives me results for cell C2. It does not go to the next line and insert the IF Formula. The weird things is that when you run the code, it places the formula in C2 as I said, but then it jumps down to cell C36. To test the function I have values in cells B2:B5, so the end result should be population of the formula in C2:C5 and then stop.
 
Upvote 0
vds1. I figured out the issue!! Your recommended add is correct! Thanks for the response and help! My formula is only specific to cell C2.
 
Upvote 0

Forum statistics

Threads
1,217,394
Messages
6,136,365
Members
450,006
Latest member
DaveLlew

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