Copying data from one sheet to another conditionally

Solved/Closed
sorceres13 Posts 2 Registration date Tuesday March 4, 2014 Status Member Last seen March 5, 2014 - Mar 4, 2014 at 02:04 PM
sorceres13 Posts 2 Registration date Tuesday March 4, 2014 Status Member Last seen March 5, 2014 - Mar 5, 2014 at 10:41 AM
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 responses

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Mar 4, 2014 at 11:07 PM
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
sorceres13 Posts 2 Registration date Tuesday March 4, 2014 Status Member Last seen March 5, 2014 1
Mar 5, 2014 at 10:41 AM
Thank you soo much that works beautifully. I appreciate the help
1