VBA For Next Loop macro

Wildman50

New Member
Joined
Dec 1, 2011
Messages
10
Hi there

I am trying to write a simple For Next loop macro and cant seem to get it right. Once i have entered the data into the first cell, i want to be able to run the macro to enable me to complete all the calculations for the next 99 rows. Is there anyone that can help me please.

This is what i have tried so far:

Sub Loopmacro()
Dim i = integer
For = i
count = 1 to 100
Range("O2").Select
ActiveCell.FormulaR1C1 = "=R[1]C[-14]"
Range("P2").Select
ActiveCell.FormulaR1C1 = "=R[1]C[-14]"
Range("C3").Select
ActiveCell.FormulaR1C1 = "=RC[17]"
Range("G3").Select
ActiveCell.FormulaR1C1 = "=R[1]C[13]"
Range("H3").Select
ActiveCell.FormulaR1C1 = "=R[2]C[12]"
Next i
End Sub


Any help would be greatful and any explanation as to why i am not getting the results i need

Many thanks in advance

Steve :confused:
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hiya
Try changing
Code:
[I]For = i
count = 1 to 100[/I]
to
Code:
For i= 1 To 100
 
Upvote 0
Hi Steve
Your Loop doesn't take into consideration for i
I needs to replace the number in the range, so instead of writing Range("O2"), it should be Range("O" & i)
But this, I think would be easier

Code:
Sub MM1()
Range("O2:O100").Formula = "=A3"
Range("P2:P100").Formula = "=B3"
Range("C3:C100").Formula = "=T3"
Range("G3:G100").Formula = "=T4"
Range("H3:H100").Formula = "=T5"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,772
Messages
6,121,456
Members
449,033
Latest member
Kcolwell16

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