+ Reply to Thread
Results 1 to 7 of 7

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

  1. #1
    Drahos
    Guest

    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.

  2. #2
    Ardus Petus
    Guest

    Re: 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" <Drahos@discussions.microsoft.com> a écrit dans le message de news:
    DB253203-2E96-4F35-9681-7F8D15B25844@microsoft.com...
    > 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.




  3. #3
    aidan.heritage@virgin.net
    Guest

    Re: 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.



  4. #4
    Bob Phillips
    Guest

    Re: 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" <Drahos@discussions.microsoft.com> wrote in message
    news:DB253203-2E96-4F35-9681-7F8D15B25844@microsoft.com...
    > 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.




  5. #5
    aidan.heritage@virgin.net
    Guest

    Re: 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" <Drahos@discussions.microsoft.com> wrote in message
    > news:DB253203-2E96-4F35-9681-7F8D15B25844@microsoft.com...
    > > 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.



  6. #6
    Bob Phillips
    Guest

    Re: 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)

    <aidan.heritage@virgin.net> wrote in message
    news:1149064298.779619.265790@j55g2000cwa.googlegroups.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" <Drahos@discussions.microsoft.com> wrote in message
    > > news:DB253203-2E96-4F35-9681-7F8D15B25844@microsoft.com...
    > > > 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.

    >




  7. #7
    Drahos
    Guest

    Re: 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" <Drahos@discussions.microsoft.com> wrote in message
    > news:DB253203-2E96-4F35-9681-7F8D15B25844@microsoft.com...
    > > 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.

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0