Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default vba create text format cells in excel 2003

I need to put char(5) into 'selected' columns in an excel 2003 worksheet
using VBA.
The problem is some of the data looks like '00123' and ends in the
spreadsheet looking like '123'. I am losing the leading zeroes. The only way
I know to make the selected range of columns is to make the selected columns
a 'text' format.
Thus using VBA can you tell me how to do the solve the problem above:
1. Do I set the selected columns to 'text' fomrat and then input the
data? If not,
2. Do I put data into the selected columns and then change the data to a
'text' format?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default vba create text format cells in excel 2003

Range("A1").NumberFormat = "@"
Range("A1") = 10

OR
Dim lngTemp As Long
lngTemp = 10
Range("A1").NumberFormat = "@"
Range("A1") = Format(lngTemp, "0000")

If this post helps click Yes
---------------
Jacob Skaria


"douglas" wrote:

I need to put char(5) into 'selected' columns in an excel 2003 worksheet
using VBA.
The problem is some of the data looks like '00123' and ends in the
spreadsheet looking like '123'. I am losing the leading zeroes. The only way
I know to make the selected range of columns is to make the selected columns
a 'text' format.
Thus using VBA can you tell me how to do the solve the problem above:
1. Do I set the selected columns to 'text' fomrat and then input the
data? If not,
2. Do I put data into the selected columns and then change the data to a
'text' format?

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default vba create text format cells in excel 2003

what does Range("A1").NumberFormat = "@" mean?

"Jacob Skaria" wrote:

Range("A1").NumberFormat = "@"
Range("A1") = 10

OR
Dim lngTemp As Long
lngTemp = 10
Range("A1").NumberFormat = "@"
Range("A1") = Format(lngTemp, "0000")

If this post helps click Yes
---------------
Jacob Skaria


"douglas" wrote:

I need to put char(5) into 'selected' columns in an excel 2003 worksheet
using VBA.
The problem is some of the data looks like '00123' and ends in the
spreadsheet looking like '123'. I am losing the leading zeroes. The only way
I know to make the selected range of columns is to make the selected columns
a 'text' format.
Thus using VBA can you tell me how to do the solve the problem above:
1. Do I set the selected columns to 'text' fomrat and then input the
data? If not,
2. Do I put data into the selected columns and then change the data to a
'text' format?

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default vba create text format cells in excel 2003

Format cell to Text
--
If this post helps click Yes
---------------
Jacob Skaria


"douglas" wrote:

what does Range("A1").NumberFormat = "@" mean?

"Jacob Skaria" wrote:

Range("A1").NumberFormat = "@"
Range("A1") = 10

OR
Dim lngTemp As Long
lngTemp = 10
Range("A1").NumberFormat = "@"
Range("A1") = Format(lngTemp, "0000")

If this post helps click Yes
---------------
Jacob Skaria


"douglas" wrote:

I need to put char(5) into 'selected' columns in an excel 2003 worksheet
using VBA.
The problem is some of the data looks like '00123' and ends in the
spreadsheet looking like '123'. I am losing the leading zeroes. The only way
I know to make the selected range of columns is to make the selected columns
a 'text' format.
Thus using VBA can you tell me how to do the solve the problem above:
1. Do I set the selected columns to 'text' fomrat and then input the
data? If not,
2. Do I put data into the selected columns and then change the data to a
'text' format?

Thanks!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default vba create text format cells in excel 2003

Alternative to the Text format, you can use a custom format of "00000". Then
the cell(s) can be SUMmed if need be.

Or, a more granular approach of preceding the value with a single quote,
e.g. '00123.


--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility

http://www.higherdata.com/sql/batchsqlfromexcel.html
Create batch SQL from Excel

"douglas" wrote in message
...
I need to put char(5) into 'selected' columns in an excel 2003 worksheet
using VBA.
The problem is some of the data looks like '00123' and ends in the
spreadsheet looking like '123'. I am losing the leading zeroes. The only
way
I know to make the selected range of columns is to make the selected
columns
a 'text' format.
Thus using VBA can you tell me how to do the solve the problem above:
1. Do I set the selected columns to 'text' fomrat and then input the
data? If not,
2. Do I put data into the selected columns and then change the data to a
'text' format?

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
Conditional Format text Excel 2003 Rhonda Excel Discussion (Misc queries) 2 October 21st 09 08:36 PM
Format cells in Excel 2003 Mazin H New Users to Excel 1 September 15th 09 10:51 AM
create mdb 2003 format by excel? Jon Excel Programming 3 October 13th 08 10:26 AM
Using Format--Style only on certain cells (Excel 2003) It Is Me Here Excel Discussion (Misc queries) 2 December 22nd 07 05:39 PM
Everytime I need to format cells or text, Excel 2003 takes a lot of time or free Florimar Agostini via OfficeKB.com Excel Discussion (Misc queries) 1 April 1st 05 06:29 AM


All times are GMT +1. The time now is 08:41 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"