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

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

Forum statistics

Threads
1,214,606
Messages
6,120,490
Members
448,967
Latest member
visheshkotha

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