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:
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,919
Office Version
  1. 365
Platform
  1. Windows
Hiya
Try changing
Code:
[I]For = i
count = 1 to 100[/I]
to
Code:
For i= 1 To 100
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,703
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,496
Messages
5,596,494
Members
414,071
Latest member
hijackhippo

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
Top