N
needhelp
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
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