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

maiwarits

New Member
Joined
Jul 17, 2022
Messages
26
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

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.

Forum statistics

Threads
1,214,968
Messages
6,122,509
Members
449,089
Latest member
RandomExceller01

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