Copying data from one sheet to another conditionally [Solved/Closed]

Report
Posts
2
Registration date
Tuesday March 4, 2014
Status
Member
Last seen
March 5, 2014
-
Posts
2
Registration date
Tuesday March 4, 2014
Status
Member
Last seen
March 5, 2014
-
Hi gang,
I have a spreadsheet with columns A thru H being populated with text. I need to copy columns A thru H from spreadsheet 1 to spreadsheet 2 if column A = to "PT". Should I be using a macro for this or an IF statement? Any help is greatly appreciated. I don't know how to create the macro and have tried the IF statement but seems like I have to create an IF state for each column

Thanks

More info:
Rows look like this:
PT ACB 1 45455550112 COMPUTER, MICRO LAP-TOP PORTABLE AC: 6910P HEWLETT PACKARD 1 130 130 Ea


So If A:A = "PT" then I need to copy the entire row to the next sheet. There may be several rows that have A:A = "PT"

Thanks

2 replies

Posts
1862
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
July 30, 2015
791
PT is column A
data in sheet is from A1
no blank rows or columns

try this macro

Sub test()
Dim r As Range, filt As Range
Application.ScreenUpdating = False
With Worksheets("sheet1")
Set r = .Range("a1").CurrentRegion
r.AutoFilter field:=1, Criteria1:="PT"
r.SpecialCells(xlCellTypeVisible).Copy
With Worksheets("sheet2")
.Range("A1").PasteSpecial
End With
.AutoFilterMode = False
End With
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2942 users have said thank you to us this month

Posts
2
Registration date
Tuesday March 4, 2014
Status
Member
Last seen
March 5, 2014
1
Thank you soo much that works beautifully. I appreciate the help
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2942 users have said thank you to us this month

Newsletter

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!