I had a workbook created for me.
I made a mistake and deleted an entire row from the Master Page and now I am getting a debug error and #REF!
on the UC-K sheet.
The error says Run-Time Error '13': Type mismatch
.
When I Debug the following line is highlighted in Yellow:
If .Cells(R, NwsLastCol).Value = 0 Then
The whole code in that section is:
Public Sub HideRows(ByRef Ws As Worksheet)
Dim R As Long
ScreenAndEvents False
With Ws
.Rows.Hidden = False
For R = NwsFirstRow To LastRow(NwsFirstCol, Ws)
If .Cells(R, NwsLastCol).Value = 0 Then .Rows(R).Hidden = True
Next R
End With
ScreenAndEvents True
End Sub
Please help!! :) I am willing to share the workbook if needed, but I'd like to know how to fix it myself as well.
On Error Resume Next
after the lineDim R As Long
. That will cause VBA to keep processing the code after encountering the cell containing the #REF error.On Error Resume Next
just shoves whatever error you get, under the carpet, letting the code happily continue with bad/unknown values. Handle errors, don't hide them!NwsFirstRow
is not a built-in VBA object; it has to be a global object defined elsewhere in the custom VBA code. By deleting that row, you've brokenNwsFirstRow
somehow. AType Mismatch
error in this context is pretty much impossible to debug without getting one's hands on the entire thing, since it could refer to.Cells
or.Value
.