+ Reply to Thread
Results 1 to 13 of 13

Adding value to cell directly below the checkbox that initiated the userform

  1. #1
    Registered User
    Join Date
    09-20-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    18

    Adding value to cell directly below the checkbox that initiated the userform

    Hi

    I’m creating an audit form that uses form control checkboxes that initiates a userform for the user to specify the type of error identified.

    Attached is the simplified file and what I would like to accomplish is as follows: Userform simplified.xlsm

    Currently, Checkbox 1 is linked to Cell B2 and Checkbox 2 is linked to Cell D2

    Both checkboxes will load the same userform when checked.

    When the “Add Error” is clicked, the VBA code is scripted to search for the next empty row within the range of (B:E) and adds the value in combo box into the 1st column and text in Remarks into 2nd column.

    My query is: How should I change the VBA code such that the values are added into the cell directly below the checkbox that initiated the userform?

    Meaning, when I add errors with the userform initiated by check box 2, the values from the userform should be added into cell D3 & E3 instead of B3 & C3.

    I have many of such checkboxes all over my audit form and manually specifying which cells to add the values is not really feasible.

    Thank You

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Adding value to cell directly below the checkbox that initiated the userform

    Crude, but works :
    Change your module code to :

    Please Login or Register  to view this content.
    and your userform code to :
    Please Login or Register  to view this content.
    Please click the * below if this helps
    Please click the * below if this helps

  3. #3
    Registered User
    Join Date
    09-20-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Adding value to cell directly below the checkbox that initiated the userform

    Thanks JasperD

  4. #4
    Registered User
    Join Date
    09-20-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Adding value to cell directly below the checkbox that initiated the userform

    Hi JasperD,

    For
    Please Login or Register  to view this content.
    How can I change the code to make it add the value at the row below the cell that the Checkbox is in automatically instead of entering "3"?

    Because my form will have many rows of the checkbox doing the same function.

    Thank you

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Adding value to cell directly below the checkbox that initiated the userform

    code in standard code module. Assign macro to both checkboxes

    Please Login or Register  to view this content.
    userform code
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  6. #6
    Registered User
    Join Date
    09-20-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Adding value to cell directly below the checkbox that initiated the userform

    Wow, That's awesome! Works like magic! Thanks Andy Pope!

    Would it be troubling to explain what each code does? I'd like to understand the code for my personal development.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Adding value to cell directly below the checkbox that initiated the userform

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-20-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Adding value to cell directly below the checkbox that initiated the userform

    Thank you very much!

  9. #9
    Registered User
    Join Date
    09-20-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Adding value to cell directly below the checkbox that initiated the userform

    Hi Andy,

    There is a small problem, when the initiated userform is closed via the "cross" instead of using cancel button, error message is prompted.

    How do I resolve it?

    Thank You.

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Adding value to cell directly below the checkbox that initiated the userform

    add this to the userform

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    09-20-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Adding value to cell directly below the checkbox that initiated the userform

    Hi Andy,

    The code works, but the msg box that prompts "error added" is displayed, any way to remove it?

    Thanks Alot!

  12. #12
    Registered User
    Join Date
    09-20-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Adding value to cell directly below the checkbox that initiated the userform

    Hi Andy,

    The code works, but the msg box that prompts "error added" is displayed, any way to remove it?

    Thanks Alot!

  13. #13
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Adding value to cell directly below the checkbox that initiated the userform

    Why not stop the user from closing the form in that way then you will know for certain whether they meant Cancel or Add Error.

    Please Login or Register  to view this content.

+ 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] Append userform checkbox selection to cell
    By lsmcal1984 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-23-2013, 06:48 PM
  2. Getting runtime error when sub executed through userform change rather than directly
    By drew.j.harrison in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-28-2013, 12:32 AM
  3. need users to enter data from userform only, not directly into cells
    By bockwich in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2012, 03:10 AM
  4. Replies: 0
    Last Post: 07-27-2012, 08:01 AM
  5. Adding Checkbox functionality to working Userform
    By rocki in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-24-2010, 02:42 PM

Tags for this Thread

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