Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert values to strings
I noramlly use the Text function to convert values. How do
I do it in VBA? I tried ActiveCell.Value = Application.WorksheetFunction.Text(ActiveCell.Valu e, "0") but it didn't work. Thanks in advance for any help. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert values to strings
You'd use any technique that would work for you manually. For example, make
the cell's number format to be Text before making the entry, or by preceding the entry with an apostrophe. With ActiveCell .NumberFormat = "@" .Value = 123 End With or ActiveCell.Value = "'123" -- Jim Rech Excel MVP "Chris" wrote in message ... |I noramlly use the Text function to convert values. How do | I do it in VBA? | | I tried ActiveCell.Value = | Application.WorksheetFunction.Text(ActiveCell.Valu e, "0") | but it didn't work. | | Thanks in advance for any help. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Convert values to strings
One way:
With ActiveCell .NumberFormat = "@" .Value = Application.Round(.Value, 0) End With Since XL's parser interprets what VBA hands it as if the value were typed, it doesn't do any good to use VBA's Format() method - the text value will simply be interpreted as a number. Hence setting the number format to Text first, so the value won't be parsed. In article , "Chris" wrote: I noramlly use the Text function to convert values. How do I do it in VBA? I tried ActiveCell.Value = Application.WorksheetFunction.Text(ActiveCell.Valu e, "0") but it didn't work. Thanks in advance for any help. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Assigning strings number values and adding them together | Excel Worksheet Functions | |||
Convert a 8X3 table to a vertical range of the Unique strings only | Excel Worksheet Functions | |||
Assigning number values to text strings | Excel Discussion (Misc queries) | |||
Convert text strings to a code or number | Excel Worksheet Functions | |||
VB Assigning Values to a Series of Strings | Excel Discussion (Misc queries) |