Copy row base on column value to another sheet with match header

maiwarits

New Member
Joined
Jul 17, 2022
Messages
34
Office Version
  1. 365
Platform
  1. Windows
Hi!

I need the code to match input value then copy data only the header show in sheet2.
But my code copy entire row and place them in the same row on sheet2 after executing.


This my data with many column and row the source data is in the column G.
1674118063617.png


Copy from sheet1 to sheet2 by match the header after click find. Like this picture.
1674118140866.png


VBA Code:
Option Explicit

Sub Test()

Dim Cell As Range

With Sheets(1)
    ''''' loop column G untill last cell with value
    For Each Cell In .Range("G1:G" & .Cells(.Rows.Count, "G").End(xlUp).Row)
        If Cell.Value = "NB016" Then
             ' Copy>>Paste
            .Rows(Cell.Row).Copy Destination:=Sheets(2).Rows(Cell.Row)
        End If
    Next Cell
End With

End Sub
 
Very good Maiwarits. You worked it out for yourself!
You can also write it as:-

VBA Code:
.AutoFilter 6, "<>Order", xlAnd, "<>Canceled"

Cheerio,
vcoolio.
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,223,893
Messages
6,175,239
Members
452,621
Latest member
Laura_PinksBTHFT

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