dpaton05
Well-known Member
- Joined
- Aug 14, 2018
- Messages
- 2,352
- Office Version
- 365
- 2016
- Platform
- Windows
I have an autofilter that appears to be filtering correctly. There will only be 1 filtered row and I am trying to assign the value in column E to the variable service. When I step through the code it stops on this line,
Here is all my code
I get the error Type mismatch. Can someone please tell me what is wrong with it?
VBA Code:
Service = .Offset(1, 5).Value
Here is all my code
VBA Code:
Sub LateCancel()
Dim ws As Worksheet, sh As Worksheet, sht As Worksheet, QT As String, wb2 As Workbook, WbPath As String, QTPath As String
Dim Serv As String, Month As String, Service As String, LCPrice As String
Set wb2 = ThisWorkbook
QT = "CSS_quoting_tool_29.5.xlsm"
Set sh = wb2.Worksheets("Totals")
'Set sht = Sheets("Cancellations")
Dim LCReq As String: LCReq = sh.Cells(32, 2).Value
Dim LCDt As String: LCDt = sh.Cells(34, 2).Value
WbPath = ThisWorkbook.Path
QTPath = ThisWorkbook.Path & "\..\" & "\..\"
Application.ScreenUpdating = False
'If Not isFileOpen(DocYearName & ".xlsm") Then Workbooks.Open ThisWorkbook.Path & "\" & "Work Allocation Sheets" & "\" & Site & "\" & DocYearName & ".xlsm"
'If Not isFileOpen(QT) Then Workbooks.Open QTPath & "\" & QT
For Each ws In wb2.Worksheets
If ws.Name <> "Cancellations" And ws.Name <> "Totals" And ws.Name <> "Sheet2" Then
With ws.[A3].CurrentRegion
'Autofilter the late cancel date enter in B34 with dates in column 1
.AutoFilter 1, LCDt
'Autofilter the late cancel request number with request numbers in column 3
.AutoFilter 3, LCReq
'Add the service to a varaible
Service = .Offset(1, 5).Value
'With Application.Intersect(.SpecialCells(xlCellTypeVisible), .Offset(1, 0))
' Serv = .Areas(1).Cells(1, 6).Address
'End With
Data.Cells(30, 1) = LCDt
Data.Cells(30, 2) = Service
LCPrice = Data.Cells(30, 8).Value
.Offset(1, 8).Value = LCPrice
.AutoFilter
End With
End If
Next ws
'sh.Range("B32,B34").ClearContents
Application.ScreenUpdating = True
End Sub
I get the error Type mismatch. Can someone please tell me what is wrong with it?