.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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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,214,905
Messages
6,122,172
Members
449,071
Latest member
cdnMech

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