OhGorgeous1
03-17-2009, 04:36 AM
Good day to you all
I have the following problem:
The below macro works great in that it autofilters the data and then copies and pastes the filtered data to a new excel sheet as long as the criteria is exact (example: N3H) but if I use a wildcard (example: N*H) then it does the autofilter section ok but then copies all the data and not the filtered data.
Can anyone please help!!
Sub AutoFilter_CopyPaste()
'activate sheet
Sheets("Data").Activate
'select rows
Rows("1:1048576").Select
' autofilter
Selection.AutoFilter Field:=7, Criteria1:=Worksheets("Menu").Range("C15").Value
'copy result
Selection.Copy
'activate sheet
Sheets("Results").Select
'paste values
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
'clear selection
Range("A1").Select
End Sub
I have the following problem:
The below macro works great in that it autofilters the data and then copies and pastes the filtered data to a new excel sheet as long as the criteria is exact (example: N3H) but if I use a wildcard (example: N*H) then it does the autofilter section ok but then copies all the data and not the filtered data.
Can anyone please help!!
Sub AutoFilter_CopyPaste()
'activate sheet
Sheets("Data").Activate
'select rows
Rows("1:1048576").Select
' autofilter
Selection.AutoFilter Field:=7, Criteria1:=Worksheets("Menu").Range("C15").Value
'copy result
Selection.Copy
'activate sheet
Sheets("Results").Select
'paste values
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
'clear selection
Range("A1").Select
End Sub