Defining a Variable

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

Hi -

I'm trying to define a variable based on the contents in a cell. I
used the variable in different times in the macro to define the month
of the year. Here is what I came up with so far.

The data I receive has the date in the following format in cell A1.
8/20/2003 12:23 PM

In my macro, I have a variable defined as follows.
month = left(A1,1)
Result - The month variable in the example above would be 8. This is
what I am looking for.

The problem I have now is that when October comes around, the month
variable will only pull the one number (1 for 10). If I change the
month variable to (month = left(A1,2)), I would get 8/ as my variable
in the example above.

Is there a way to add an if statement in defining a variable.

Thanks.
Stephen
 
Back
Top