Object Requi

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

why am i getting the error "object required" when i try to use this code?



Private Sub CommandButton1_Click()
Dim numberoption As Range

Sheets("Sheet3").Select
SweetenerOptions.Hide

Set numberoption = Application.InputBox("How many senarios would you
like to consider:", "Options")
numberoption.Value = number

If number = 1 Then
PriceChoices.Label1.Enabled = True
End If

If number = 2 Then
PriceChoices.Label1.Enabled = True
PriceChoices.Label2.Enabled = True
End If
 
if SweetenerOptions
isnt the code name of a worksheet (or a reference set to some object) then
that would raise the error.

Sub AA()
v = TypeName(Application.InputBox("How many senarios would you like to
consider:", "Options"))
Debug.Print v

End Sub

returns string, so you can't use

Set numberoption = Application.InputBox . . .

and this is backwards:

numberoption.Value = number

it would be
dim numberoption as string
numberoption = Application.InputBox
dim number as Long
nummber = clng(numberoption)
 
Set numberoption = Application.InputBox("How many senarios would you
like to consider:", "Options")
**********************************
I don't think the above will work: You are asking for an integer or perhaps
a Long when you have already dimmed "numberperson" as a range.
 
numberoption.Value = number
*************************
In the above, is **number** a public variable? If not, it is not dimmed.
What is it's value?
Perhaps you meant to reverse the above:
number = numberoption.value
???????????????
 

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

Back
Top