+ Reply to Thread
Results 1 to 13 of 13

Checkbox Can I do This

  1. #1
    Forum Contributor
    Join Date
    08-22-2008
    Location
    S-o-t
    MS-Off Ver
    Office 2000 & 2010
    Posts
    166

    Checkbox Can I do This

    I have a userform that contains 15 labels, each label has Numbers in it each time i click on a label the text is inserted into an excel spreadsheet. I use it as a fast input solution and works well and has done for a few years.

    I Now want to Add three checkboxes to the userform
    If checkbox One is ticked i want the letter "A" and the number in the label i choose to be inserted into the spreadsheet.
    Checkbox Two "B"
    Checkbox Three "c"

    I would only ever tick one of the checkboxes never two or three so it would be A, B or C

    This is the code for The Labels i use

    Please Login or Register  to view this content.
    and so on

    This is the Call Insert textselection

    Please Login or Register  to view this content.
    The userform works by doubleclick

    Hope you Can help

    Dave
    Last edited by Dave69rock; 08-25-2008 at 06:14 PM. Reason: wrap code

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

    Please remember to wrap your code using the Code tags.

    How to wrap your Code
    On the Message window Toolbar you will see the # icon. This will automatically wrap the text you selected with the proper VB tags to create a Code Window in your post. You can do this manually by placing the tag [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] at the end.

    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    08-22-2008
    Location
    S-o-t
    MS-Off Ver
    Office 2000 & 2010
    Posts
    166
    Didn't know still new to the site

    its done and will be in future

  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,259
    Hello Dave69rock,

    The easiest solution would be to declare a Public string variable to hold the letter. The Click event of each check box would set this variable to the proper letter (checked) or clear it (unchecked).

    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor
    Join Date
    08-22-2008
    Location
    S-o-t
    MS-Off Ver
    Office 2000 & 2010
    Posts
    166
    Thanks leith my knowledge of vb isn't to that standard any chance of an example.

    Dave

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    You could change this line in InsertTextSelection
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

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

    I'll need a little time to put together a sample workbook for you as a guide.

    Sincerely,
    Leith Ross

  8. #8
    Forum Contributor
    Join Date
    08-22-2008
    Location
    S-o-t
    MS-Off Ver
    Office 2000 & 2010
    Posts
    166
    Leith thanks for taking the time just to do this.

    I'm on this forum to lean so time is not important

    Cheers again Dave

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

    The example workbook has one UserForm, 8 labels, and 3 OptionButtons. The OptionButtons are better in this case than CheckBoxes. Options buttons are mutually exclusive, i.e. only one can be set at a time. When any label is clicked, the prefix letter is attached to the label caption and placed in the active cell. All this code is in the UserForm...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    08-22-2008
    Location
    S-o-t
    MS-Off Ver
    Office 2000 & 2010
    Posts
    166
    Leith

    Wow this is great many thanks
    Dave

  11. #11
    Forum Contributor
    Join Date
    08-22-2008
    Location
    S-o-t
    MS-Off Ver
    Office 2000 & 2010
    Posts
    166
    Mikerickson thanks for your reply

    i can't seem to get it to work i replaced the Call InsertTextSelection with what you said.

    Dave

  12. #12
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    I expressed myself poorly. Leave the calls for the sub as they are and change the sub to
    Please Login or Register  to view this content.
    b

  13. #13
    Forum Contributor
    Join Date
    08-22-2008
    Location
    S-o-t
    MS-Off Ver
    Office 2000 & 2010
    Posts
    166
    Mikerickson

    Thank you so much i love how your code works.

    Dave

+ 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. checkbox cell range change vba
    By novitaun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2008, 12:53 PM
  2. Checkbox and recalculate
    By lemonstar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2008, 11:31 AM
  3. How to have Checkbox A uncheck with checked Checkbox B
    By Texas Aggie 09 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2007, 09:29 AM
  4. Checkbox - Date
    By bmasella in forum Excel General
    Replies: 1
    Last Post: 05-09-2007, 12:57 PM
  5. text box input and checkbox on user form
    By raw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2007, 05:27 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