ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inputbox to enter a % (https://www.excelbanter.com/excel-programming/358489-inputbox-enter-%25.html)

StephanieH

Inputbox to enter a %
 
I'm tring to use an Input Box to enter a percentage. I'm entering 7.8 but
the cell shows 780.00%

Here's what I have (that's applicable)
Dim ACR As String
ACR = InputBox("ACR?")
Range("G47").Select
ActiveCell.NumberFormat = "0.00%"
ActiveCell.Value = "" & ACR & ""

I've also tried
ActiveCell.Value = "" & ACR & "" * 0.01
and
ActiveCell.Value = "" & ACR & "" / 100
but I get a Type Mismatch
When I try to declare the variable as in Integer, I get a Type Mismatch as
soon as I enter 7.8

I know I could enter .078 and my problem would be solved, but I'll have
other folks running this too. It makes more sense to be able to enter 7.8
and get 7.8% or 7.80% displayed.

Please help.

Toppers

Inputbox to enter a %
 
Try this:

Dim ACR As String
ACR = InputBox("ACR?")
ACR = ACR * 0.01
Range("G47").Select
ActiveCell.NumberFormat = "0.00%"
ActiveCell.Value = "" & ACR & ""
ActiveCell.Value = ACR '<=== Why not this ?
End Sub

"StephanieH" wrote:

I'm tring to use an Input Box to enter a percentage. I'm entering 7.8 but
the cell shows 780.00%

Here's what I have (that's applicable)
Dim ACR As String
ACR = InputBox("ACR?")
Range("G47").Select
ActiveCell.NumberFormat = "0.00%"
ActiveCell.Value = "" & ACR & ""

I've also tried
ActiveCell.Value = "" & ACR & "" * 0.01
and
ActiveCell.Value = "" & ACR & "" / 100
but I get a Type Mismatch
When I try to declare the variable as in Integer, I get a Type Mismatch as
soon as I enter 7.8

I know I could enter .078 and my problem would be solved, but I'll have
other folks running this too. It makes more sense to be able to enter 7.8
and get 7.8% or 7.80% displayed.

Please help.


Papou

Inputbox to enter a %
 
Hello
acr = Application.InputBox("ACR", , , , , , , 1)
Range("g47").FormulaR1C1 = acr / 100
Range("g47").NumberFormat = "0.00%"


HTH
Cordially
Pascal

"StephanieH" a écrit dans le message
de news: ...
I'm tring to use an Input Box to enter a percentage. I'm entering 7.8 but
the cell shows 780.00%

Here's what I have (that's applicable)
Dim ACR As String
ACR = InputBox("ACR?")
Range("G47").Select
ActiveCell.NumberFormat = "0.00%"
ActiveCell.Value = "" & ACR & ""

I've also tried
ActiveCell.Value = "" & ACR & "" * 0.01
and
ActiveCell.Value = "" & ACR & "" / 100
but I get a Type Mismatch
When I try to declare the variable as in Integer, I get a Type Mismatch as
soon as I enter 7.8

I know I could enter .078 and my problem would be solved, but I'll have
other folks running this too. It makes more sense to be able to enter 7.8
and get 7.8% or 7.80% displayed.

Please help.




StephanieH

Inputbox to enter a %
 
Thank you. It works perfectly.

You know, I have no idea why I haven't been entering my variables that way.
(Activecell.Value = ACR). I guess the first time I used a variable, this
was the way I saw it and it worked. Bad habit to get into.... Thanks for
the reminder.

"Toppers" wrote:

Try this:

Dim ACR As String
ACR = InputBox("ACR?")
ACR = ACR * 0.01
Range("G47").Select
ActiveCell.NumberFormat = "0.00%"
ActiveCell.Value = "" & ACR & ""
ActiveCell.Value = ACR '<=== Why not this ?
End Sub

"StephanieH" wrote:

I'm tring to use an Input Box to enter a percentage. I'm entering 7.8 but
the cell shows 780.00%

Here's what I have (that's applicable)
Dim ACR As String
ACR = InputBox("ACR?")
Range("G47").Select
ActiveCell.NumberFormat = "0.00%"
ActiveCell.Value = "" & ACR & ""

I've also tried
ActiveCell.Value = "" & ACR & "" * 0.01
and
ActiveCell.Value = "" & ACR & "" / 100
but I get a Type Mismatch
When I try to declare the variable as in Integer, I get a Type Mismatch as
soon as I enter 7.8

I know I could enter .078 and my problem would be solved, but I'll have
other folks running this too. It makes more sense to be able to enter 7.8
and get 7.8% or 7.80% displayed.

Please help.



All times are GMT +1. The time now is 08:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com