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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
73,250
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
21,282
Office Version
  1. 365
  2. 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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,190
Messages
5,835,896
Members
430,393
Latest member
hetherton

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