VBA Language to convert whole number to percentage

NinaE_11

New Member
Joined
Aug 18, 2020
Messages
40
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!
 

Some videos you may like

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.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,616
Office Version
  1. 365
Platform
  1. Windows
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.
 
Solution

NinaE_11

New Member
Joined
Aug 18, 2020
Messages
40
Office Version
  1. 2016
Platform
  1. Windows
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.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,616
Office Version
  1. 365
Platform
  1. Windows
Sorry, you were too quick and replied while I was making edits to my previous post! ;)
Take a look at the revised suggestion.
 

NinaE_11

New Member
Joined
Aug 18, 2020
Messages
40
Office Version
  1. 2016
Platform
  1. Windows
Sorry, you were too quick and replied while I was making edits to my previous post! ;)
Take a look at the revised suggestion.
Outstanding!! Thank you SO much!
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
56,616
Office Version
  1. 365
Platform
  1. Windows
You are welcomne.
Glad it worked for you.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,444
Messages
5,624,809
Members
416,055
Latest member
EJGAJG

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
Top