VBA code to automatically insert a row below based on criteria

Cyberpunk001

New Member
Joined
Aug 27, 2018
Messages
13
Good day,

I need VBA code to automatically insert a row below or inbetween rows based on criteria.
In the example below, I need code to run row by row to check if the "OVER" column >0,
if that case is true, it will check 3 conditions:

1) Check the "HOURS" column for the max hours such as 10.5
2) Check the EMP ID column for a unique ID such as 0001
3) Check the WEEKDAY column for values not equal to 7

Based on these three conditions, it will insert a row below the 10.5 HOURS column in this example. (see A5:D5)

Once the new row is inserted, it will copy over all the data in each column from the row above, except for the "HOURS" column,
instead it will take the OVER value which in 0001's case is 2.5 and put that in the HOURS column for the new row.

EMP ID(A1)HOURSWEEKDAYOVER
0001912.5
00011022.5
000110.532.5
NEW 0001 A52.5 OVER B53 C52.5 D5
0001942.5
0001962.5
0001972.5
00021021.5
00029.2531.5
00029.2541.5
0002951.5
0002961.5 (D12)

<tbody>
</tbody>

The actual file has thousands of rows of data such as above, with many more columns of data, each EMP ID is in such a format as above.
Any help will be appreciated :)
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,214,907
Messages
6,122,183
Members
449,071
Latest member
cdnMech

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