ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Syntax error.. (https://www.excelbanter.com/excel-programming/365915-syntax-error.html)

Freddie Mac

Syntax error..
 
I have a macro that sets a value to a Range varaible. I then want to check
the contents of the variable and if there is no contents I want to give a
message in a message box. My code is:

Dim rng1 As Range
Set rng1 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(1),
LookIn:=xlValues)

If IsEmpty(rng1) = True Then
MsgBox ("Cannot find " & varWorksheetInfoArray(2))
End If

It worked before but now there seems to be a problem since I just get the
uninformative Syntax Error.

NickHK

Syntax error..
 
Try:
If rng1 Is Nothing...
IsEmpty is used to test Variants, whilst MyVar Is Nothing is used to test
Objects.

NickHK

"Freddie Mac" wrote in message
...
I have a macro that sets a value to a Range varaible. I then want to check
the contents of the variable and if there is no contents I want to give a
message in a message box. My code is:

Dim rng1 As Range
Set rng1 =
Worksheets(varWorksheetInfoArray(0)).Cells.Find(va rWorksheetInfoArray(1),
LookIn:=xlValues)

If IsEmpty(rng1) = True Then
MsgBox ("Cannot find " & varWorksheetInfoArray(2))
End If

It worked before but now there seems to be a problem since I just get the
uninformative Syntax Error.





All times are GMT +1. The time now is 12:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com