Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default number formatting

Get message next to cell, formatted text or apostrophe.
If I use format, cell, number, number: it doesn't always solve problem.
If I use the message, "convert to number" it always works.
Want macro that I can use on a selected range of cells that performs the
conversion using that process.
THX
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default number formatting

Hi Scottie -

If all cells in the selection are non-empty and contain only numeric
characters (with or without the leading apostrophe), Scottie01 will work
properly. If your selection contains some empty cells or some cells with
alpha characters, use Scottie02 (it won't convert empty cells and alpha cells
to "0" as will Scottie01). Both are included for demonstration purposes, but
I'd suggest Scottie02 because it's more universal.

Sub Scottie01()
For Each itm In Selection
itm.Value = Val(itm)
Next 'itm
End Sub

Sub Scottie02()
For Each itm In Selection
On Error Resume Next
If itm < "" Then itm.Value = CSng(itm.Value)
Next 'itm
End Sub
----
Jay


"Scottie" wrote:

Get message next to cell, formatted text or apostrophe.
If I use format, cell, number, number: it doesn't always solve problem.
If I use the message, "convert to number" it always works.
Want macro that I can use on a selected range of cells that performs the
conversion using that process.
THX

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 formatting R Ormerod Excel Discussion (Misc queries) 1 July 30th 08 12:52 PM
Number Formatting Steve Haack Excel Discussion (Misc queries) 1 July 30th 08 12:32 AM
Formatting a number Michel Khennafi Excel Worksheet Functions 2 July 9th 07 05:42 PM
formatting cell number based on previous cell number Pasquini Excel Discussion (Misc queries) 3 June 20th 06 06:36 AM
Number Formatting Delaina Excel Worksheet Functions 3 June 9th 05 06:15 PM


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