Add +1 in every for Next Loop

hansgrandia

Board Regular
Joined
Jan 10, 2015
Messages
53
Hello,

For below standing code, I like would like to add one for every loop. Starting week is 1 and should be 2 in het second loop until the max number of weeks is reached (Loopcounter). Could someone help me out?

Thanks,
Hans Grandia
Netherlands

Code:
Sub Budget_Hourensou()
Dim Counter As Integer
Dim Rowcounter As Integer
Dim Startweek As Integer
Dim Loopcounter As Integer
Dim i As Integer

'Worksheet activeren
Worksheets("INPUT").Activate
Rowcounter = Application.CountA(Range("A:A"))

'Bepaal het aantal weken
Startweek = 0
Counter = 1
Loopcounter = WorksheetFunction.Max(Range("F2:F" & Rowcounter)) 'number of weeks 
'Column invoegen voor Budget
Columns("L:L").Select
Selection.Insert Shift:=xlToRight
Selection.NumberFormat = "General"
Range("L1").Value = "BUDGET"
Range("L2").Select
Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Offset(1, 0).Select
'Add Budget hours of Nico per week
For Loopcounter = Rowcounter To Rowcounter + Loopcounter
ActiveCell.Offset(0, 2).Value = "NICO"
ActiveCell.Offset(0, 4).Value = "TSP"
[COLOR=#FF0000]ActiveCell.Offset(0, 5).Value = Counter + Loopcounter 'weeknumber should add with +1 every loop[/COLOR]
ActiveCell.Offset(0, 11).Value = "4"
ActiveCell.Offset(1, 0).Select
ActiveCell.Offset(0, 2).Value = "NICO"
ActiveCell.Offset(0, 4).Value = "OPS"
[COLOR=#FF0000]ActiveCell.Offset(0, 5).Value = Counter + Loopcounter 'weeknumber should add with +1 every loop[/COLOR]
ActiveCell.Offset(0, 11).Value = "20"
ActiveCell.Offset(1, 0).Select
ActiveCell.Offset(0, 2).Value = "NICO"
ActiveCell.Offset(0, 4).Value = "VAL"
[COLOR=#FF0000]ActiveCell.Offset(0, 5).Value = Counter + Loopcounter 'weeknumber should add with +1 every loop[/COLOR]
ActiveCell.Offset(0, 11).Value = "8"
ActiveCell.Offset(1, 0).Select
ActiveCell.Offset(0, 2).Value = "NICO"
ActiveCell.Offset(0, 4).Value = "ACM"
[COLOR=#FF0000]ActiveCell.Offset(0, 5).Value = Counter + Loopcounter 'weeknumber should add with +1 every loop[/COLOR]
ActiveCell.Offset(0, 11).Value = "8"
ActiveCell.Offset(1, 0).Select
Next Loopcounter
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
counter = counter + 1
Next Loopcounter

should do it
 
Upvote 0
Thank you mole999. Where should I put the code "counter = counter + 1"? Your support is appreciated!
Hans Grandia
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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