Help Please :) I'm VBA Stumped

  • Thread starter Thread starter Marc
  • Start date Start date
M

Marc

an Shout out to all Excel Wizards!!


My Problem, take populated cells from column A of sheet 1 and search
and copy rows from sheet 2 that match the certain of column E, and
paste full rows to sheet3 until all cells in sheet 1 have been used up.
Im trying to have it run from VBA with a button on sheet 1 or a macro.

this is what I have to work with.

Sheet 1 (Paste in UserID numbers, ending row varys)
Column Names Column Letter
UserID----------------------A


Sheet 2 (All Records, updates monthly, ending row varys)

Column Names Column Letter
FirstName -------------------A
LastName--------------------B
UserName-------------------C
Password--------------------D
UserID-----------------------E

Sheet 3(Generated back on search results "Rows" found from Sheet 2)

Column Names Column Letter
FirstName -------------------A
LastName--------------------B
UserName-------------------C
Password--------------------D
UserID-----------------------E


Thank You in advance for your reading time and of any help you could
provide!!

~ Marc
 
If your data has headers in row1 on both Sheet1 and Sheet2 , you can do it
with Advanced Filter. If not, put headers there. The header in Sheet1, A1
should be the same as Sheet2, E1.

Sub CopyData()
Dim rng As Range
With Worksheets("Sheet1")
Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
End With
Sheets("sheet2").Range("A1") _
.CurrentRegion.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=rng, CopyToRange:=Worksheets( _
"Sheet3").Range("A1"), Unique:=False
End Sub


Assume sheet3 is blank.
 
Back
Top