Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning strings number values and adding them together JRD Excel Worksheet Functions 2 June 23rd 09 10:08 PM
Convert a 8X3 table to a vertical range of the Unique strings only מיכאל (מיקי) אבידן ® Excel Worksheet Functions 8 May 2nd 09 08:13 AM
Assigning number values to text strings [email protected] Excel Discussion (Misc queries) 0 December 8th 06 09:52 PM
Convert text strings to a code or number MaxNY23 Excel Worksheet Functions 15 March 23rd 06 10:47 PM
VB Assigning Values to a Series of Strings cincode5 Excel Discussion (Misc queries) 1 August 4th 05 11:38 PM


All times are GMT +1. The time now is 07:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"