Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Convert a number to text and add a comma separator for thousands

I have a Text Box in a User Form that I am creating. The Text Box's
value is set to a number without decimals.

For example:
Dim rents As Long
rents = 4102
rentsTxtBox.Value = rents

So when the number passes to the Text Box, I want it to display like
this: 4,102. Basically, is there an vba function for excel that
converts a number to a string and then adds the comma separator for
thousands? If not what code would I use to do this?

Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Convert a number to text and add a comma separator for thousands

Hi
In VBA use
Format(rents, "#,##0")

The #,##0 is a custom number format in Excel that you can see in
Format, Cells..., Custom.
regards
Paul

prahz wrote:

I have a Text Box in a User Form that I am creating. The Text Box's
value is set to a number without decimals.

For example:
Dim rents As Long
rents = 4102
rentsTxtBox.Value = rents

So when the number passes to the Text Box, I want it to display like
this: 4,102. Basically, is there an vba function for excel that
converts a number to a string and then adds the comma separator for
thousands? If not what code would I use to do this?

Thanks.


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
Number Format: Convert No. to thousands Faraz A. Qureshi Excel Discussion (Misc queries) 3 January 27th 10 01:16 PM
separator of thousands Antonio Excel Discussion (Misc queries) 0 April 4th 08 01:28 AM
thousands comma separator in VBA Wendy Francis Excel Discussion (Misc queries) 2 October 25th 05 01:14 AM
separator of thousands excelFan Excel Discussion (Misc queries) 2 December 27th 04 12:27 PM
comma s separator text file T. Alksndr rstrpo Prado Excel Programming 0 September 15th 03 10:41 PM


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

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"