tanyaleblanc
Board Regular
- Joined
- Mar 16, 2019
- Messages
- 145
I'm getting an error "type mismatch" on the ws1 name, not sure why, It worked last month, can someone help me understand.
Sub FinanceOwnedFilter2()
Dim lRow As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Dim i As Long, lastrow As Long
If AutoFilterMode = True And FilterMode = True Then ActiveSheet.ShowAllData
lRow = ActiveSheet.Range("A500").End(xlUp).Row
Set ws1 = "Billed"
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
.Title = "Please select the file."
' Clear out the current filters, and add our own.
.Filters.Clear
'.Filters.Add "Excel 2003", "*.xls"
'.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the
' user picked at least one file. If the .Show method returns
' False, the user clicked Cancel.
If .Show = True Then
txtfilename = .SelectedItems(1) 'replace txtFileName with your textbox
'MsgBox txtfilename
Workbooks.Open txtfilename
End If
End With
'Debug.Print ActiveWorkbook.Name
Set ws1 = Billed
lRow = ActiveSheet.Range("a500").End(xlUp).Row
With ActiveSheet("Billed")
.AutoFilterMode = False
With Range("a2:m" & lRow)
.AutoFilter
.AutoFilter field:=1, Criteria1:="Payout"
End With
End With
'--------
Dim rang As Range
Set ws2 = Owned
Sub FinanceOwnedFilter2()
Dim lRow As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Dim i As Long, lastrow As Long
If AutoFilterMode = True And FilterMode = True Then ActiveSheet.ShowAllData
lRow = ActiveSheet.Range("A500").End(xlUp).Row
Set ws1 = "Billed"
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
.Title = "Please select the file."
' Clear out the current filters, and add our own.
.Filters.Clear
'.Filters.Add "Excel 2003", "*.xls"
'.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the
' user picked at least one file. If the .Show method returns
' False, the user clicked Cancel.
If .Show = True Then
txtfilename = .SelectedItems(1) 'replace txtFileName with your textbox
'MsgBox txtfilename
Workbooks.Open txtfilename
End If
End With
'Debug.Print ActiveWorkbook.Name
Set ws1 = Billed
lRow = ActiveSheet.Range("a500").End(xlUp).Row
With ActiveSheet("Billed")
.AutoFilterMode = False
With Range("a2:m" & lRow)
.AutoFilter
.AutoFilter field:=1, Criteria1:="Payout"
End With
End With
'--------
Dim rang As Range
Set ws2 = Owned