ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA Numbers to Text or Date to Text (https://www.excelbanter.com/excel-discussion-misc-queries/122700-vba-numbers-text-date-text.html)

EagleOne

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



All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com