Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Replace - Excel 2003

Status
Not open for further replies.

BigNorton

IS-IT--Management
Jun 22, 2011
5
US
I'm really new to VBA and have a question about Selection.Replace on a cell with numeric values. The quest -- change cells with value '0' to 'UK'. Examples of cell values -- 0; 10; 102; 14, etc. With the following code the each '0' in the value changes to 'UK', so in my examples you get UK; 1UK; 1UK2; 14 -- see my problem. The code --
Columns("A:A").Select
Selection.Replace What:="0", Replacement:="UK", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

I'm new, so be kind.

 


hi,

So what's the problem?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip,

The problem is that I'd like to look at the number as a whole -- only change a zero value to UK. So, in my example the results would be --
Value Results
0 UK
10 10
107 107
1.02 1.02

Sorry if I wasn't clear.
 


your answer is in this property
[tt]
LookAt:=xlPart
[/tt]
the constant is xlWhole.

However, why are you MIXING text and numbers in the same column???

That is a recepie for disaster.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip,

Thanks for the direction -- I'll do some looking at the property so that I can understand where I went wrong. I appricate your help and input.

Your question as to why the mixing of numbers and text in the same column -- I need the value of zero to really stand-out from any of the numeric values as it indicates that more research needs to be done (has to do with part numbers and their weight). That column is informational only and not used in any formulas, so I thought to make it text (UK) would make it stand-out.

Again, thanks for pointing me in the right direction.

BigNorton

 


There are other much better ways of emphasizing values, without CHANGING the value.

You could use COnditional Formatting.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip,

Thanks for the tip -- I will look into Conditional Formatting for this task. Again, I thank you for your help -- you've got me going in the right direction.

BigNorton
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top