ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro prompts for a number to be used in this macro as a variable (https://www.excelbanter.com/excel-programming/362881-macro-prompts-number-used-macro-variable.html)

Drahos

Macro prompts for a number to be used in this macro as a variable
 
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.

Ardus Petus

Macro prompts for a number to be used in this macro as a variable
 
i=application.inputbox("Prompt","Title",type:=1)

type:=1 requests a numerical value.

HTH
--
AP

"Drahos" a écrit dans le message de news:
...
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.




[email protected]

Macro prompts for a number to be used in this macro as a variable
 
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

Drahos wrote:
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.



Bob Phillips

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

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)

"Drahos" wrote in message
...
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.




[email protected]

Macro prompts for a number to be used in this macro as a variable
 
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!

Bob Phillips wrote:
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)

"Drahos" wrote in message
...
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.



Bob Phillips

Macro prompts for a number to be used in this macro as a variable
 
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)

wrote in message
oups.com...
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!

Bob Phillips wrote:
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)

"Drahos" wrote in message
...
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.





Drahos

Macro prompts for a number to be used in this macro as a varia
 
Dear Bob and Aidan,

the advice is fine. It works. Thanks a lot.
Drahos

"Bob Phillips" wrote:


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)

"Drahos" wrote in message
...
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.






All times are GMT +1. The time now is 02:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com