TheRedCardinal
Active Member
- Joined
- Jul 11, 2019
- Messages
- 250
- Office Version
- 365
- 2021
- Platform
- Windows
Hi all,
My macro does this:
At the first IF statement, I am getting a "Range of Object Worksheet failed" error.
When I hover over WorkingRange, I get the preview of "01/10/2022" - so it has found and offset properly.
So - which referencing protocol have I got wrong?
My macro does this:
- Opens a new workbook from a specified file name
- Sets Sheets(1) worksheet as variable WS3
- Looks for the word "Date" in WS3
- Sets a variable "WorkingRange" as the cell it found, offset by 1 row and 0 columns
- Checks whether the month of "WorkingRange" matches the value in a named cell in another worksheet ("WS1")
Excel Formula:
Set WorkingRange = WS3.UsedRange.Find("Date").Offset(1, 0)
If WorkingRange <> "" Then
If Month(WS3.Range("WorkingRange")) <> WS1.Range("RepMonth") Then
CellA.Offset(0, 6) = "No"
SubTest = False
Else
CellA.Offset(0, 6) = "Yes"
End If
Else
CellA.Offset(0, 6) = "n/a"
End If
At the first IF statement, I am getting a "Range of Object Worksheet failed" error.
When I hover over WorkingRange, I get the preview of "01/10/2022" - so it has found and offset properly.
So - which referencing protocol have I got wrong?