Hi All,
I am working on some VBA code and got stuck with "If" statement.
In general I want macro to filter proper columns basing o cell values and copy paste the result to another tab. This is my code so far:
I am working on some VBA code and got stuck with "If" statement.
In general I want macro to filter proper columns basing o cell values and copy paste the result to another tab. This is my code so far:
Code:
Sub test()
Sheets("Tommy").Activate
'Hotw to loop it so the macro can be done for each row?
Select Case Range("h3").Value
Case Is = "Tab1"
Range("k3:s3").Copy
Sheets("Tab1").Activate
Range("c2:k2").PasteSpecial
Case Is = "Tab2"
Range("k3:s3").Copy
Sheets("Tab2").Activate
Range("c2:k2").PasteSpecial
End Select
Sheets("Tommy").Activate
'I want the macro to filter column J of Tab2/Tab1 to show only rows with "Y" in column J, and then copy columns from B to H and paste them to "Fianl" tab.
If Range("G3") = "Global" And Range("h3") = "Tab2" Then
Sheets("Tab2").Select
Rows("5:5").Select
Range("J5").Activate
Selection.AutoFilter
ActiveSheet.Range("$a$5:$m$5").AutoFilter field:=11, Criteria1:="<>"
End If
End Sub