Need macro to copy and insert row below active cell

Savuti

Board Regular
Joined
Apr 30, 2008
Messages
156
Hello folks, I have posted what I have manged to piece together. The macro does copy row 6 and insert it below the cell in D column that has the word "OK" in it. At some point I need to delete an entire row when the word "NO" is entered in a cell in D column. I need help setting up the delete part of the macro.
With the curent macro if I delete a row then I get a run time error 13 - Type mismatch. Can you please help with this.



Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Application.EnableEvents = False
   Application.ScreenUpdating = False
    If ((Target.Value = "OK") And (Target.Column = 4)) Then
   
       Rows("6:6").Select
       Selection.Copy
   
        Target.Offset(1, 0).EntireRow.Insert
        Application.CutCopyMode = False
       Range("B2").Select
       
    End If
    Application.ScreenUpdating = True
    Application.EnableEvents = True
  End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Maybe I need a new macro altogether. I have tried a few variations of what I have with no luck. Really need help with this - thanks
 
Upvote 0
Had to bump this to the top, does what I am asking make sense, I don't believe this is too complicated but I simply cannot get this to work.
 
Upvote 0
Please ignor the macro I have include at the top of this thread. What I am looking for is VBA code to do the following: when the word "OK" is entered into a cell in column D then row 6 is copied and inserted below the cell with the word "OK".

I have tried a few variations and connot get this. Thanks
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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