Insert rows with data when criteria is met
Solved/Closed
jan
-
May 7, 2010 at 11:48 PM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - May 8, 2010 at 01:49 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - May 8, 2010 at 01:49 AM
Related:
- Excel auto insert row when data changes
- Grand theft auto v free download no verification for pc - Download - Action and adventure
- Facebook auto refresh - Guide
- Auto download mms when roaming - Guide
- Grand theft auto iv download apk for pc - Download - Action and adventure
- Transfer data from one excel worksheet to another automatically - Guide
1 response
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
May 8, 2010 at 01:49 AM
May 8, 2010 at 01:49 AM
introduce row1 and give column headings. now it will look
suppose this is in sheet1
fruit type
Apple Mac
Apple Green
Apple Bartlett
right click this sheets tab and click view code
in the resulting window copy this "event code"
now just click apple in sheet 1 and see what you get in sheet 2
the macro undo clears sheet2 so that you can again choose "apple" and
recheck .
suppose this is in sheet1
fruit type
Apple Mac
Apple Green
Apple Bartlett
right click this sheets tab and click view code
in the resulting window copy this "event code"
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim dest As Range, cfind As Range, x As String Dim j As Integer, y As String, add As String If Target.Column <> 1 Then Exit Sub x = Target.Value Set cfind = Cells.Find(what:=x) j = cfind.Row x = cfind.Offset(0, 1).Value add = cfind.Address With Worksheets("sheet2") Set dest = .Cells(Rows.Count, "A").End(xlUp).Offset(1, 0) dest = "row" & " " & j dest.Offset(0, 1) = x End With Do Set cfind = Cells.FindNext(cfind) If cfind Is Nothing Then Exit Do If cfind.Address = add Then Exit Do j = cfind.Row x = cfind.Offset(0, 1).Value With Worksheets("sheet2") Set dest = .Cells(Rows.Count, "A").End(xlUp).Offset(1, 0) dest = "row" & " " & j dest.Offset(0, 1) = x End With Loop End Sub
now just click apple in sheet 1 and see what you get in sheet 2
the macro undo clears sheet2 so that you can again choose "apple" and
recheck .
Sub undo() Worksheets("sheet2").Cells.Clear End Sub