I have a VBA application which loops through the cells in a column in Excel. Each cell is tested for a particular value - ="N". When I run the application it seems to ignore this test and carries on regardless.
When debugging the code I get a 'Run-time error 91 Object variable or With block variable not set ' message, even though I've Set the sheet object.
I've attached the code below.
Dim wbInput As Workbook
Dim wsInputSource As Worksheet
Dim sFileName As String
On Error Resume Next
' OPEN THE REQUIRED WORKBOOK
sFileName = Application.GetOpenFilename
Set wbInput = Workbooks.Open(sFileName)
' TEST IF NEW BUSINESS
Application.ScreenUpdating = False
Set wsInputSource = wbInput.Sheets("Manchester")
For r = 2 To 50
If wsInputSource.Cells(r, 2).Value = "N" Then
If wsInputSource.Cells(r, 3) <> 0 Then
wsInputSource.Cells(r, 4).value = "New"