Automatically duplicate and insert a row based on a cell value in that row.

AFnav04

New Member
Joined
Apr 18, 2019
Messages
1
I have a sheet that I am entering in values for to layout power requirements.
My table has a colum for Devce Name, PDU Location, Max Power (W), Max Current (A) [this is automatically calculated based on he power field divided by 120V], Breaker value [auomaticly looked up based on a defined list of values (5, 10, 20)]. If I enter a current that exceeds 20A I need to create a second line becuase this will require two breakers. I dont want to have to go through and manually add rows every time I run across this issue.
 

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
I will assume your headers start in column A and are contiguous, making the amperage column D. The code goes into your standard code module1.
Code:
Sub t()
Dim i As Long
    With ActiveSheet 'Be sure hou have the sheet you want the row added to is active
        For i = .Cells(Rows.Count, 4).End(xlUp).Row To 2 Step -1
            If .Cells(i, 4).Value > 20 Then
                .Rows(i).Copy 'assumes 2nd breaker will be the same.
                .Rows(i + 1).Insert
                Application.CutCopyMode = False
            End If
        Next
    End With
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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