hansgrandia
Board Regular
- Joined
- Jan 10, 2015
- Messages
- 53
Hello,
In order to compare data, it's necessary for me to copy rows based on the number of networkdays (which is calculated). So if networkdays is 2, another additional row is needed below the original row. If networkdays is 10, there are 9 additional rows required below that specific row (or perhaps on other sheet). Preferable with calculating one additional working in column 8 (Date_Begin). This for all rows in the sheet. No action required if Networkdays is 1.
Does a person see the key for this problem? Thank you, Hans Grandia (Netherlands)
In order to compare data, it's necessary for me to copy rows based on the number of networkdays (which is calculated). So if networkdays is 2, another additional row is needed below the original row. If networkdays is 10, there are 9 additional rows required below that specific row (or perhaps on other sheet). Preferable with calculating one additional working in column 8 (Date_Begin). This for all rows in the sheet. No action required if Networkdays is 1.
Does a person see the key for this problem? Thank you, Hans Grandia (Netherlands)
VBA Code:
Sub insert_rows_based_Workdays()
Dim LastRow As Long
Dim Networkday As Long
'insert column for calculation working days
Columns("H").Insert
Range("H1").Value = "Working Days"
'Determine Last_Row
With ActiveSheet
LastRow = .Range("A1").SpecialCells(xlCellTypeLastCell).Row
End With
'Formula for working_days
For i = 2 To LastRow
Cells(i, 8).Formula = Application.WorksheetFunction.NetworkDays(Cells(i, 6), Cells(i, 7))
Next i
Columns("H:H").Select
Selection.NumberFormat = "General"
'Copy lines based on number of Networkdays
For i = 2 To LastRow
NetworkDays = Cells(i, 8).Value
'?
End Sub