Insert row, run macro from Drop down List and copy row above.

JorgenKjer

Board Regular
Joined
Aug 1, 2016
Messages
65
Office Version
  1. 2013
Platform
  1. Windows
Hi

Are there anyone who can help?

If I insert a row e.g. between rows 10 and 11 and in the new row I select SUB or RSD from the Drop Down List in column D, the values ​​in the row above the new row, must be copied down, except values ​​in columns H and I. In the new row, these cells must be blank.

If I in the new row select SAFE, OPS or CAT from the Drop down List in column D, only the values ​​above the new row in columns J and K must be copied down, all other cells must be blank.

The formatting must be copied too.

Part ofthe text is in Danish, I hope it does not confuse.

I hope all this makes sense.

Regards

Jorgen


https://www.dropbox.com/home/Mr. Excel?preview=IC4+Vedligeholdelsesplan+MACRO.xlsm
 
Last edited:

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hello,

Does this code meet you requirements?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    If Target.Column = 4 Then
        If Target.Value = "SUB" Or Target.Value = "RSD" Then
            Range("E" & Target.Row - 1 & ":G" & Target.Row - 1).Copy Range("E" & Target.Row)
            Range("J" & Target.Row - 1 & ":K" & Target.Row - 1).Copy Range("J" & Target.Row)
        Else
            Range("J" & Target.Row - 1 & ":K" & Target.Row - 1).Copy Range("J" & Target.Row)
        End If
    End If
    Application.EnableEvents = True
End Sub

the code needs to go into the relevant sheet code window, not a standard module.
 
Upvote 0
Hello Onlyadrafter

Thanks for the help, the code works perfectly.

Greeting
Jorgen
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

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