Thread: Use of Variable
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Use of Variable

You need to make vcol1 equal to something.
If it is to be a column index number then something like:
vcol1 = 3 ' this would be Colummn C and you could use it like:
Cells(2, vcol1).Copy Cells(5, 15) 'copy from Range("C2") to Range("O5")
If you want it to equal a date value then:
vcol1 = Jan ' to use it you would have to be sure that the data type is
compatible
with the place it is applied.

The Dim statement only declares the data type. It does not assign the value
to the variable. You must use the equal sign and in cases where you are
defining an object variable, also use The Set command to assign a value to
the variable.

Those variables that do not have the Set command can have their values
changed later in the code by simply making them equal to something else. But
don't try changing them within the same loop, that won't work.

"Jim May" wrote:

If in a standard module I have an interger variable and I wish to be able to
use this variable later in a sheet_change event, what exactly would I do?
Above the Standard module I put:

Global vcol1 as Interger

But I'm not sure what else I am to do in order to have it later to use in my
Sheet_Change event code.