Replacing specific text within a table cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have identified a specific textrange that I want to replace text in, but am
not sure how to go about doing it. I want to change "M" to "" and "$" to ""
in that text range. Can someone assist?

Thanks,
Barb Reinhardt
 
Hi Barb

Is this "M" and" $" as discreet words or within other words. Surely
replacing all M's with "" would give some unexpected results?
 
It's with specifically identified cells and is not a global change. I've
actually determine how to do this, but the results are now strings and I need
them to be numeric. How can I resolve this?

Thanks,
Barb Reinhardt
 
Barb Reinhardt said:
It's with specifically identified cells and is not a global change. I've
actually determine how to do this, but the results are now strings and I need
them to be numeric. How can I resolve this?

Textranges contain strings, never numerics. I'm guessing you need to convert values
like "$500M" to something that you can convert to numerics?

Something like this, assuming you've got the value you want to work with in sTemp, a
string variable:

sTemp = Replace(sTemp,"M","")
sTemp = Replace(sTemp,"$","")
' and depending on whether you plan to use val(sTemp) or cdbl(sTemp) or
' something else to convert to numeric, you may also want to
' eliminate commas
sTemp = Replace(sTemp,",","")

Now Cdbl(sTemp) or Val(sTemp) gives you a numeric
 
Back
Top