vba copy/pase (multiple) rows below/other sheet based on criteria (networkdays)

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)

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
 

Attachments

  • Picture.png
    Picture.png
    24.4 KB · Views: 18

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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