Replace Substitute

woodymcglathery

New Member
Joined
Jun 3, 2022
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Good morning,

Here is a portion of a macro I am working on. It would move the decimal point, for example (14.3 to .143), in order to format the number to %. It works fine however, until the whole number is 100. It will then ultimately change it to 10%. I know that if I were to edit the code below to "=REPLACE(SUBSTITUTE(E2,""."",""""),2,0,""."")+0" then it will enable the number to actually show 100%. Yet, we both know what that does to all numbers below 100. I am struggling with wording the If/Then or whatever other code I should insert. Hopefully I am making sense in what I need help for.

Range("D2").Select
ActiveCell.Value = "=REPLACE(SUBSTITUTE(E2,""."",""""),1,0,""."")+0"
Selection.Style = "Percent"
Selection.NumberFormat = "0.0%"
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Why not just divide the values by 100 and then apply your formatting?
 
Upvote 0
Solution
You are welcome!
Glad I was able to help.
 
Upvote 0

Forum statistics

Threads
1,215,446
Messages
6,124,900
Members
449,194
Latest member
JayEggleton

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