Macro prompts for a number to be used in this macro as a variable

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

Guest

Dear All,
could anyone help me to write a part of a macro which will prompt to
input a number. This number will be used in the same macro as a number
variable to specify a condition. I mean a user will be prompted to input the
lowest invoice value. This value can be for example 540.50. This figure
should be used later in the same macro as condition to delete rows having a
smaller value in an appropriate cell. I need a help to write the part of the
macro promting for the input and to assign the input figuer to a variable.
Thank you very much for your help.
Drahos.
 
i=application.inputbox("Prompt","Title",type:=1)

type:=1 requests a numerical value.

HTH
 
sub GetANumber
MyNumber=val(inputbox("Please enter a number"))
'HOWEVER, user can type anything they like into an input box
'A UserForm would be a better solution OR a cell on the workbook, as
both
'could be restricted to numeric input only
end sub
 
myNum = Application.InputBox("Input number",Type:=1)
If myNum = 0 then exit Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Thanks Ardus and Bob for correcting my information - I had not come
across application.inputbox before - I will remember this in future as
it's kinda useful!!! You never stop learning!
 
It's most useful with Type:=8, that allows the user to select a range from
the worksheet.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

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