.Replace not working

jarekjd

New Member
Joined
Jan 5, 2018
Messages
11
Guys,

i have a simple code:

Code:
   With Rows("3")
      .Replace What:=",", Replacement:="", LookAt:=xlPart, _
         SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
         ReplaceFormat:=False
   End With
icon.png




The goal is to change the regional settings. I want to get rid of "," which means decimal places in my region.

Unfortunatelly this is not working :(

IN the cells there are just values with general format like 7,100. After macro it should be 7100.

I run Ctrl+H manualy and this is working. Once in macro - it doesn't :(

pls support
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
How about this instead?

Code:
   With Rows("3")
      .NumberFormat = "@"
      .Replace What:=",", Replacement:="", LookAt:=xlPart, _
         SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
         ReplaceFormat:=False
   End With

WBD
 
Upvote 0
wideboydixon,

thx for your reply. The cells are formatted now as text but the replace function is still not working :(
 
Upvote 0
Hmmm. That is odd. I ran a quick test and your code worked for me when the cells are formatted as text.

WBD
 
Upvote 0
and that was the trick - i need to use "." although i see ",". I think it is an issue of regional settings.

One last thing. Once i do the same operations with % (eg. 20,4%) i still don't see them as a number. In excel there is an exclamation mark and it gives an option: "convert to number".

I was trying to record this action but it gives empty output.

I use also:

Code:
.NumberFormat = "#,##0"
.NumberFormat = "0%"
icon.png



but it's not working, too :(

any ideas?
 
Upvote 0
This is working until somebody can write it more professinally ;)

Code:
   With Rows("13")
      .NumberFormat = "General"
      .Value = .Value
      .NumberFormat = "0%"
   End With
 
Upvote 0

Forum statistics

Threads
1,223,905
Messages
6,175,297
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top