+ Reply to Thread
Results 1 to 5 of 5

Macro to deduct entered value

  1. #1
    Registered User
    Join Date
    06-19-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Macro to deduct entered value

    Hi,
    Recently I made an Excel spreadsheet (Excel 2003) and used macros to add a specific amount to each cell when clicked. While setting up the spreadsheet, I had encountered another macro method that I am trying to do now.

    The macro was simply, when a cell was selected and the macro button click, a small window would pop up (with user written description) and you input the amount you wanted to deduct, and the macro would do it. Now I can't find the website I learnt that from and I'm in real need of it. Would anyone be able supply the macro code for this function, or direct me to the right place?

    Example, I click on a cell and then click the macro. A pop up window would appear, and the window has instructions that I created in the script editor ("Enter the amount you would like to deduct") and I would input the amount into the small box ("5"). The macro would then deduct 5 from the cell.

    Thanks in advance.
    Last edited by The Last Day Dawns; 06-20-2010 at 09:39 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Macro to deduct entered value

    are you thinking of a macro like this


    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-19-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Macro to deduct entered value

    venkat1926, Thank you so much! That it exactly what I was looking for. Thanks for your help.

    Edit: Just a problem I've encountered. Is there a way to stop it from Runtime error if I cancel or 'x' the pop-up window? It says Runtime error 13.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro to deduct entered value

    Hello The Last Day Dawns,

    The VBA InputBox returns an empty string when the user clicks Cancel.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    06-19-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Macro to deduct entered value

    Thank you very much, Leith Ross. It works beautifully now. The students will be very happy!

+ 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.6.0 RC 1