VBA Language to convert whole number to percentage

NinaE_11

Board Regular
Joined
Aug 18, 2020
Messages
54
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I'm setting values in one spreadsheet from another using the following code:

Workbooks("Template_VBA.xlsm").Worksheets("Char").Range("E11").Value = _
Workbooks("Characteristics.xlsx").Worksheets("Active").Range("B37").Value

The original value in B37 on the "Active" worksheet is a whole number of 29.3, which I need to reflect as 29.3% in the destination worksheet ("Char"). I have a whole page of these I need to convert over into these percentages for a presentation using the below code, however, whatever I'm doing is giving me a result of 2930%.

With Range("E11")
.Value = .Value / 100
.NumberFormat = "0.0%"
End With

Anything help would be great - thank you!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
It works just fine for me, if cell E11 is hard-coded and not a link/formula.
If it is a link/formula, you will need to update your formula to divide by 100.

Why not just do:
Rich (BB code):
Workbooks("Template_VBA.xlsm").Worksheets("Char").Range("E11").Value = _
    Workbooks("Characteristics.xlsx").Worksheets("Active").Range("B37")/100
and then you can format the range.
 
Upvote 0
Solution
What exactly is in cell E11?
Is it hard-coded, or is it a formula?
If it is a formula, you will need to update your formula to divide by 100.
The number is cell E11 is hard-coded, downloaded from an external source.
 
Upvote 0
Sorry, you were too quick and replied while I was making edits to my previous post! ;)
Take a look at the revised suggestion.
 
Upvote 0
You are welcomne.
Glad it worked for you.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,602
Members
449,089
Latest member
Motoracer88

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