+ Reply to Thread
Results 1 to 10 of 10

Userform and for Inventory

  1. #1
    Registered User
    Join Date
    01-03-2021
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    8

    Userform and for Inventory

    I have searched around, but am unable to find anything specific to what I am wanting to do. Basically, I am creating an inventory worksheet, and wanting a userform to come up when data is entered into a cell. For example, when a UPC is entered into a cell, a userform comes up asking for a quantity to be entered. The user is presented with an OK or Cancel button. I have found examples to have the userform come up on a change event, and entering a quantity and hitting OK enters that value into a desired cell. However, what I am wanting for the cancel button is to not just close the userform, but also clear the contents of the "Target" cell that triggered the userform.

    Hope that makes sense and someone can help with my VBA!

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,938

    Re: Userform and for Inventory

    Hi and welcome

    What range of cells will trigger the userform and where should the number entered be output to?

    BSB

  3. #3
    Registered User
    Join Date
    01-03-2021
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    8

    Re: Userform and for Inventory

    The entered data is added to Column C of my sheet, and the data entered on the userform is entered on the same row, but two columns over. I have all of that working; you enter a UPC in a cell of column C, a userform comes up and asks to enter a quantity. I entere a quantity, click enter, and that data is entered into a cell two columns over. What I am after is if you instead click "cancel" and not OK, the form closes and clears the data in the cell that initiated the userform.w

    For example, cell C4 has data entered into it, userform pops up, but Cancel is clicked. The userform goes away and the data entered into C4 is cleared. This should repeat regardless of the row - C4, C5, C6, etc.

    This is the code I have for the cancel button:

    Please Login or Register  to view this content.
    And this is the main code for the sheet:
    Please Login or Register  to view this content.
    I think my challenge comes from using "Target" rather than the cell specifically...
    Last edited by jswilbur81; 01-04-2021 at 05:42 PM.

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,938

    Re: Userform and for Inventory

    Forum rules dictate that I cannot help further until you add code tags to your last post. Edit the post, highlight the code then click on the # icon in the buttons above the text window then save the changes.
    It may be worth also adding a sample workbook as it will be easier to help with that.

    BSB

  5. #5
    Registered User
    Join Date
    01-03-2021
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    8

    Re: Userform and for Inventory

    I changed the code above per your suggestions and uploaded a sample worksheet
    Attached Files Attached Files
    Last edited by jswilbur81; 01-04-2021 at 05:47 PM.

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,938

    Re: Userform and for Inventory

    Try this in your worksheet module:
    Please Login or Register  to view this content.
    This in your userform module:
    Please Login or Register  to view this content.
    Add this to the standard module:
    Please Login or Register  to view this content.
    See attached. Does that do what you need?

    BSB
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-03-2021
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    8

    Re: Userform and for Inventory

    That works exactly as I wanted, thank you! Is it easy enough to add additional fields to this without to much hassle - like, if I wanted to add a Name or Location field?

  8. #8
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,938

    Re: Userform and for Inventory

    Glad I could help

    Add additional fields in what way? So the form has more than just quantity on it?

    BSB

  9. #9
    Registered User
    Join Date
    01-03-2021
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    8

    Re: Userform and for Inventory

    Meant like adding additional fields besides just quantity, and have those entered fields be entered into other cells on the worksheet. After some fiddling, I figured it out. Thanks again for your help!

  10. #10
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: Userform and for Inventory

    One I submitted a few weeks back to another post.
    It may prove a useful approach.
    torachan.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Automate barcode scanning into an inventory sheet to add to actual inventory and subtract
    By Robert7474 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-28-2020, 12:06 PM
  2. adjusting code add message quantity for inventory on userform
    By ABDELFATTA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2020, 04:33 AM
  3. Replies: 0
    Last Post: 09-04-2018, 02:52 AM
  4. Inventory deducted userform to affect excel database.
    By Shwan79 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2018, 05:46 PM
  5. [SOLVED] Excel Userform Inventory
    By azmir in forum Excel General
    Replies: 1
    Last Post: 04-10-2016, 01:24 AM
  6. Inventory Sheet updated continuously by a UserForm
    By gmcconnell in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-03-2013, 02:19 PM
  7. [SOLVED] userform misses data when inventory input
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-25-2013, 02:54 PM

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