craigs23
New Member
Hi All,
I am hoping somenone will be able to help.
what am trying to achieve is, I have code which allowsme to filter raw dat this filtred data is then copied and pasted to a seperate sheet on the next empty row.
The data is always posted starting in column "A" which is fine for customer 1 however what I am trying to do if I change the filter to customer 2 then this dat should be copied to the same sheet as customer 1 but instead of column "A" it should be pasted to column "H".
I have pasted the code I have so far below.
Can anyone Help?
Thanks in advance
I am hoping somenone will be able to help.
what am trying to achieve is, I have code which allowsme to filter raw dat this filtred data is then copied and pasted to a seperate sheet on the next empty row.
The data is always posted starting in column "A" which is fine for customer 1 however what I am trying to do if I change the filter to customer 2 then this dat should be copied to the same sheet as customer 1 but instead of column "A" it should be pasted to column "H".
I have pasted the code I have so far below.
Code:
Sub Sample()
Dim wb1 As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
Dim copyFrom As Range
Dim lRow As Long
Dim strSearch As String
Set wb1 = ThisWorkbook
Set ws1 = wb1.Worksheets("Sheet3")
ws1.Activate
strSearch = "Customer1"
With ws1
.AutoFilterMode = False
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
With .Range("C1:C" & lRow)
.AutoFilter Field:=1, Criteria1:="=*" & strSearch & "*"
Set copyFrom = .Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow
End With
.AutoFilterMode = False
End With
Set ws2 = wb1.Worksheets("Sheet4")
With ws2
ws2.Activate
lRow = ws2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
copyFrom.Copy .Rows(lRow)
End With
On Error Resume Next
End Sub
Can anyone Help?
Thanks in advance