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
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