LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Problem with retaining numbers formatted as text after code runs

I am running code to check through each column in a worksheet and make
substitutions for various characters, e.g.

For i = 1 To numcols
For j = 1 To numrows - 1
fvalue = ActiveCell.Offset(j, 0)
Call cleanse_data
ActiveCell.Offset(j, 0).Value = StrConv(fvalue,
vbUpperCase)
Next

Sub cleanse_data()
'data cleansing routine

fvalue = Application.WorksheetFunction.Substitute
(fvalue, "&", " AND ")
fvalue = Application.WorksheetFunction.Substitute
(fvalue, "#", " NO. ")
fvalue = Application.WorksheetFunction.Substitute
(fvalue, "/", " ")
fvalue = Application.WorksheetFunction.Substitute
(fvalue, "/", " ")
fvalue = Application.WorksheetFunction.Substitute
(fvalue, "_", " ")
fvalue = Application.WorksheetFunction.Substitute
(fvalue, " ", " ")
fvalue = Application.WorksheetFunction.Substitute
(fvalue, " ", " ")
End sub

my problem is that when the value is written back into the cell
"numbers" which were previously formatted as text revert to a number
format, e.g. "000888" reverts to "888".

How can I run this code, or similar code and retain the original
formatting?

I can't use a leading apostraphe as these values are uploaded to
database system.

Would appreciate any input ...
Julie
 
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
numbers formatted as text willemeulen[_28_] Excel Discussion (Misc queries) 13 June 8th 09 02:25 PM
a code to trace pure numbers formatted as Text swordsman Excel Programming 4 September 3rd 07 11:28 PM
formatted numbers to CSV problem mark Excel Programming 6 November 15th 05 11:09 PM
Pivot Table keep apart cells text that I've formatted as numbers Paulo Bevervanso Excel Worksheet Functions 2 September 21st 05 08:45 PM
Converting numbers formatted as text to numbers Bill Excel Discussion (Misc queries) 1 July 19th 05 07:10 PM


All times are GMT +1. The time now is 02:11 AM.

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

About Us

"It's about Microsoft Excel"