Hi again, so I have this file selection thing working ok, so the address of the file that i want to use as a data source is in cell "Z2", but I am not sure of the correct syntax for referencing it.
I figured it would be "Indirect" but i get a 'Compile Error' "Sub or function not defined". Actually, i am having a hard time even asking the question in the correct syntax, google is not gifting me appropriate information!
I then want to get this code, written by Fluff, to work on the external file. (I know, I should have specified that to start with but, tbh, i didn't expect so much help, so i started small ... live and learn!)
This code works on sheets in the same workboook. it loops through each sheet and applies an auto-filter and copies the whole row where the filter value is found to a targetsheet in the same workbook.
I want to separate the Targetsheet and the source sheet.
so, i wont need the If statement, as there will be no chance of that conflict. I think what i need to do is define wb as workbook and then set it as the value in the cell Z2, of the active sheet.
Sub Davavo4()
Dim Ws As Worksheet, Trgtws As Worksheet
Dim UsdRws As Long
Set Trgtws = Sheets("TargetSheet")
For Each Ws In Worksheets
Ws.Columns("k").Hidden = False
UsdRws = Ws.Range("L" & Rows.Count).End(xlUp).Row
Ws.Range("A7:L" & UsdRws).AutoFilter 12, "*zhan*"
Ws.AutoFilter.Range.Offset(1).EntireRow.Copy Trgtws.Range("L" & Rows.Count).End(xlUp).Offset(1, -11)
Ws.AutoFilterMode = False
Next Ws
End Sub
Thanks for any help in advance. Learning VBA is Hard.
I figured it would be "Indirect" but i get a 'Compile Error' "Sub or function not defined". Actually, i am having a hard time even asking the question in the correct syntax, google is not gifting me appropriate information!
I then want to get this code, written by Fluff, to work on the external file. (I know, I should have specified that to start with but, tbh, i didn't expect so much help, so i started small ... live and learn!)
This code works on sheets in the same workboook. it loops through each sheet and applies an auto-filter and copies the whole row where the filter value is found to a targetsheet in the same workbook.
I want to separate the Targetsheet and the source sheet.
Code:
Sub Davavo4()
Dim Ws As Worksheet, Trgtws As Worksheet
Dim UsdRws As Long
Set Trgtws = Sheets("TargetSheet")
For Each Ws In Worksheets
If Ws.Name <> Trgtws.Name Then
Ws.Columns("k").Hidden = False
UsdRws = Ws.Range("L" & Rows.Count).End(xlUp).Row
Ws.Range("A7:L" & UsdRws).AutoFilter 12, "*zhan*"
Ws.AutoFilter.Range.Offset(1).EntireRow.Copy Trgtws.Range("L" & Rows.Count).End(xlUp).Offset(1, -11)
Ws.AutoFilterMode = False
End If
Next Ws
End Sub
so, i wont need the If statement, as there will be no chance of that conflict. I think what i need to do is define wb as workbook and then set it as the value in the cell Z2, of the active sheet.
Sub Davavo4()
Dim Ws As Worksheet, Trgtws As Worksheet
Dim UsdRws As Long
Set Trgtws = Sheets("TargetSheet")
For Each Ws In Worksheets
Ws.Columns("k").Hidden = False
UsdRws = Ws.Range("L" & Rows.Count).End(xlUp).Row
Ws.Range("A7:L" & UsdRws).AutoFilter 12, "*zhan*"
Ws.AutoFilter.Range.Offset(1).EntireRow.Copy Trgtws.Range("L" & Rows.Count).End(xlUp).Offset(1, -11)
Ws.AutoFilterMode = False
Next Ws
End Sub
Thanks for any help in advance. Learning VBA is Hard.
Last edited: