Macro to Insert Row in selected cell (Dynamic selection)

harinsh

Active Member
Joined
Feb 7, 2012
Messages
273
Hi Team,
I have two similar sheets with different formulas (reference linked). I would need macro code in order to insert row in any selected cell (dynamic) the same thing needs to be updated (inserted in this case) to another similar sheet with same reference range.

Example:
There are two sheets 1) Sheet1 & 2) Sheet2
If I insert row in Sheet1 - A2 cell then same needs to be inserted in Sheet2.

Please help me on this.

Thanks,
Harish
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try something like this

It inserts the row on the current worksheet which should be sheet 1 and also on another sheet named sheet 2

Code:
Sub Insertrwo()
    Dim wks As Worksheet
    Dim k As Integer
    
    Set wks = Worksheets("Sheet2")
        k = ActiveCell.Row
        ActiveCell.EntireRow.Insert shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        
        wks.Activate
        wks.Rows(k).Select
        Selection.Insert shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End Sub

Let's see how it goes
 
Upvote 0
May I request you to please provide me row delete or remove for the same tasks.
Thanks,

Maybe something like this
Code:
Sub delrows()
    Dim wks As Worksheet
    Dim k As Integer
    
    Set wks = Worksheets("Sheet2")
        k = ActiveCell.Row
        ActiveCell.EntireRow.Delete shift:=xlUp
        
        wks.Activate
        wks.Rows(k).Select
        Selection.Delete shift:=xlUp
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,616
Messages
6,125,860
Members
449,266
Latest member
davinroach

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