Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Formatting zipcodes as text in worksheet cells

I am trying to convert a worksheet column of 5 digit numeric zipcodes to
text in order to keep leading zeros (1234 should be 01234). If I enter
"=Text(A1,"00###")" in the cell I want, it will convert cell A1. However if
I use the following VBA code, I get no leading zero:

ActiveSheet.Cells(intRow, IntCol+1) =
Application.WorksheetFunction.Text(ActiveSheet.Cel ls(intRow, intCol).Value
, "00###")

I tried the following code with the same results (no leading zero added):

ActiveSheet.Cells(intRow, IntCol+1) = Format(ActiveSheet.Cells(intRow,
intCol).Value, "00###")

Does anyone know how to use VBA to format text in a worksheet cell?

Thanks,
Bob Ward


  #2   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Formatting zipcodes as text in worksheet cells

Try on of these instead:

ActiveSheet.Range("A1").NumberFormat = "00000"
ActiveSheet.Cells(intRow, intCol).NumberFormat = "00000"

tod

-----Original Message-----
I am trying to convert a worksheet column of 5 digit

numeric zipcodes to
text in order to keep leading zeros (1234 should be

01234). If I enter
"=Text(A1,"00###")" in the cell I want, it will convert

cell A1. However if
I use the following VBA code, I get no leading zero:

ActiveSheet.Cells(intRow, IntCol+1) =
Application.WorksheetFunction.Text(ActiveSheet.Ce lls

(intRow, intCol).Value
, "00###")

I tried the following code with the same results (no

leading zero added):

ActiveSheet.Cells(intRow, IntCol+1) = Format

(ActiveSheet.Cells(intRow,
intCol).Value, "00###")

Does anyone know how to use VBA to format text in a

worksheet cell?

Thanks,
Bob Ward


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Formatting zipcodes as text in worksheet cells

ActiveSheet.Cells(intRow, IntCol+1) = Format(ActiveSheet.Cells(intRow,
intCol).Value, "00###")


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bob Ward" wrote in message
...
I am trying to convert a worksheet column of 5 digit numeric zipcodes to
text in order to keep leading zeros (1234 should be 01234). If I enter
"=Text(A1,"00###")" in the cell I want, it will convert cell A1. However

if
I use the following VBA code, I get no leading zero:

ActiveSheet.Cells(intRow, IntCol+1) =
Application.WorksheetFunction.Text(ActiveSheet.Cel ls(intRow, intCol).Value
, "00###")

I tried the following code with the same results (no leading zero added):

ActiveSheet.Cells(intRow, IntCol+1) = Format(ActiveSheet.Cells(intRow,
intCol).Value, "00###")

Does anyone know how to use VBA to format text in a worksheet cell?

Thanks,
Bob Ward




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
Formatting Text in cells that already have text entered Jennifer V. Excel Worksheet Functions 4 January 13th 09 09:27 PM
Vlookup with large file of zipcodes DTTODGG Excel Worksheet Functions 4 December 17th 08 02:44 AM
How do I lock the formatting of my worksheet but still add text? Y2Kate Excel Worksheet Functions 2 July 10th 08 10:49 AM
Not printing 0 in zipcodes from excel spreadsheet. iamdevoe Excel Discussion (Misc queries) 1 December 22nd 05 03:42 PM
How do I convert 9 digit zipcodes to 5 digits? Robert Judge Excel Discussion (Misc queries) 3 November 18th 05 05:57 PM


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