Using Input Box results in a formula

P

PaulSinki

Hi, I was hoping someone could help me.
I've got a macro that asks the user for two inputs, defined as MyValue
and MyValue2. How do I use the results in a formula though?
This is the code that I have currently:

MyValue1 = Application.InputBox("How many days is the current event?")
MyValue2 = Application.InputBox("How far through the current even
are you?")
Range("Y1").Select
ActiveCell.FormulaR1C1 = "=[MyValue1]/[MyValue2]"

However, it crashes out on putting the formula in. How do I correctl
call the results of MyValue1 & 2 and put them into a formula?

Any help greatly appreciated!
Thanks,
Pau
 
D

Don Guillett

Sub dividedays()
Range("b1").Value = InputBox("How many days in event") / InputBox("How far
through")
End Sub

Don Guillett
SalesAid Software
(e-mail address removed)
 
G

Gord Dibben

Paul

Why do you need a formula entered into Y1?

You can enter the computed value directly.

Public Sub qwerty()
Dim MyValue1 As Long
Dim MyValue2 As Long
MyValue1 = InputBox("How many days is the current event?")
MyValue2 = InputBox("How far through the current event are you?")
Range("Y1").Select
ActiveCell.Value = MyValue1 / MyValue2
End Sub

Gord Dibben Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top