View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Phil Phil is offline
external usenet poster
 
Posts: 31
Default Variable not working

Hi all,

I'm sure I've missed something very simple, but I can't get this bit
of code to work - the result keeps coming up with #NAME!

I have installed the analysis toolpack and RANDBETWEEN works fine as a
formula.

However, the code works fine if I just have the code enter strInput
into a cell - but fails when I enter it into the formula.


Sub fred()
Dim strInput As String
strInput = InputBox("Input Number")
Range("I4").Select
ActiveCell.FormulaR1C1 = "=RANDBETWEEN(1,strInput)"
End Sub

Can anyone help?
Many thanks in advance

Phil