View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
J.E. McGimpsey J.E. McGimpsey is offline
external usenet poster
 
Posts: 493
Default Variable produces a complie error

"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


In article ,
"Btinker" wrote:

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.