type mismatch and/or obj req error from inputbox

  • Thread starter Thread starter goaljohnbill
  • Start date Start date
G

goaljohnbill

In the following code snippet i get different errors depending on how
i dim prrsplat. As variant i get "type mismatch" on the input box, as
integer or double i get "object req" on the variable. The goal for the
code is to have the input not be greater than the "fixed" maximum and
highlight the a section of the original counted range based on how
much of the range the user wants. I hunted around for an answer here
but couldnt find anything that applied closely enough for me to apply
it and work.

thanks in advance

Sheets("PRRS").Select
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Dim numprrs As Double
Dim prrsmaxplat As Double
Dim trunprrs As Integer
Dim prrsplat As Double
Dim prrshl As Integer
numprrs = Selection.Rows.Count
prrsmaxplat = numprrs / 43
trunprrs = Fix(prrsmaxplat)
Do
Set prrsplat = Application.InputBox(Prompt:=("How many plates
to run" & vbLf & "Max plates allowed " & trunprrs), Title:="Number
plates to print/run", Type:=1)
Loop Until prrsplat <= trunprrs
prrshl = prrsplat * 43
' more code from here once this works
 
The set statement is only required when the variable is an object such as a
worksheet or a range. You are using regular variables so you want to drop the
"Set" something like this...

Sheets("PRRS").Select
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Dim numprrs As Double
Dim prrsmaxplat As Double
Dim trunprrs As Integer
Dim prrsplat As Double
Dim prrshl As Integer
numprrs = Selection.Rows.Count
prrsmaxplat = numprrs / 43
trunprrs = Fix(prrsmaxplat)
Do
prrsplat = Application.InputBox(Prompt:=("How many plates
to run" & vbLf & "Max plates allowed " & trunprrs), Title:="Number
plates to print/run", Type:=1)
Loop Until prrsplat <= trunprrs
prrshl = prrsplat * 43
 
The set statement is only required when the variable is an object such as a
worksheet or a range. You are using regular variables so you want to drop the
"Set" something like this...

It worked!! Things like this are hard to figure out on your own when
you are copy and paste/1-2 books self taught. This is an excellent
resource Thank you for your time
 

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

Similar Threads


Back
Top