Insert line based on cell

MattMaxWarehouse

New Member
Joined
Oct 12, 2017
Messages
4
I have a spreadsheet with multiple sheets. I am trying to set it up so if sheet 2 D30 has a value, a row auto inserts on sheet 1 line 4.
I have been looking for a while and can't find anything that does what I need. Any help would be greatly appreciated.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi & welcome to MrExcel
Try this
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address <> "$D$30" Or Target.Count > 1 Then Exit Sub
        If Len(Target) > 0 Then
            Sheets("[COLOR=#0000ff]Data[/COLOR]").Rows(4).Insert
            Sheets("[COLOR=#0000ff]Data[/COLOR]").Range("D4").Value = Target.Value
        End If

End Sub
Change the name in blue to match your sheet name.
This need to go into the sheet module.
Right click on the sheet you change, click view code & then paste the code into the window that opens up

ps This inserts the value into D4 as this is the row that was added
 
Last edited:
Upvote 0
Sorry,

Ok I didn't phrase it correctly. What I'm trying to do is Sheet 2 Cell U2 is my control. If U3 doesn't match I want to add a row on sheet 1 between lines 2 and 3 and fill sheet 1 cell I3 (the New line) with the info from Sheet 2 cell D31. I actually need to do this with several cells, but if you can get me started I can finish the rest.
 
Upvote 0
Ok try this
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address <> "$U$2" Or Target.Count > 1 Then Exit Sub
        If Target.Value <> Range("U3").Value Then
            Sheets("[COLOR=#0000ff]Data[/COLOR]").Rows(2).Insert
            Sheets("[COLOR=#0000ff]Data[/COLOR]").Range("I3").Value = Range("D31").Value
        End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,360
Messages
6,124,489
Members
449,166
Latest member
hokjock

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