VBA Numbers to Text or Date to Text
Note to Google Search Groups
Populating worksheet cells with information that looks like numbers
or date-like functions i.e. MONTH(), DAY() etc, Excel may "assume"
what you mean, which in turn, can cause unexpected issues later.
For example,
I had sheetnames "Jan06", Feb06 etc. I transferred the sheet names
to another worksheet's cells. When done, the cell information became
1-06.
When I wanted to compare information and/or "Goto" those sheets,
Jan06 is very different from 1-06.
Therefore, to force Numbers to Text or Date to Text, consider
concatenating
Range("B2").Value = "'" & Range("A1").Text or
Range("B2").Value = "'" & Activesheet.name
to force Excel to interpret that
Jan06 as Jan06 and not 1-06.
Simularly:
To force Excel to intrepret 1234 as Text:
Range("B2").Value = "'" & Range("A1")
HTH EagleOne
|