Variable produces a complie error

  • Thread starter Thread starter Btinker
  • Start date Start date
B

Btinker

I have a macro that takes a variable value from a cell on
a specific sheet. This worked just fine the first three
months we ran the thing and now I get "Compile error:
Object required".

Am I missing something? I can't figure out what's wrong.

Dim myMonth as Integer
Set myMonth = Worksheets ("BANNER DATA").Range ("A2")

The cell has the correct number in it.

Thanks for any help you can offer.
 
"Set" is used in assigning an object to an object variable. You're
assigning the default range property (.Value) to an integer variable.
To assign a value, you can use the optional Let (or, like 99.99% of
users, leave it out).

Dim myMonth As Integer
Let myMonth = Worksheets("BANNER DATA").Range("A2").Value

or

Dim myMonth As Integer
myMonth = Worksheets("BANNER DATA").Range("A2").Value
 
Back
Top