Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to select cells in column enter data then press enter | New Users to Excel | |||
Enter multiple numbers in a cell so total shows when enter keypres | Excel Worksheet Functions | |||
Enter info in one sheet, auto enter in another based on one field | New Users to Excel | |||
Inputbox and Application.InputBox | Excel Programming | |||
Inputbox to enter date | Excel Programming |