+ Reply to Thread
Results 1 to 11 of 11

VBA Checkbox code complement

  1. #1
    Registered User
    Join Date
    10-08-2015
    Location
    Gothenburg
    MS-Off Ver
    2016
    Posts
    78

    VBA Checkbox code complement

    Hey guys.

    I got this code which works perfect. When I type in a specific word it automaticly checks the checkbox with that name. But I would want to add a thing to this code, if the box that is autochecked is ticked, I want the code to check another code named the same thing.

    Like if Zon 1 is checked, also check words ending with Zon 1. etc ~

    For ex. see picture.

    Zon.jpg

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: VBA Checkbox code complement

    Ignore - board lurgies.
    Last edited by cytop; 06-10-2016 at 03:41 AM.

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: VBA Checkbox code complement

    You could try a simplistic change first:

    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Obviously, I have no idea of the data you're working with and there is a chance it will check something you do not want checked - if that happens, the only solution is to process specific checkboxes rather than all...

  4. #4
    Registered User
    Join Date
    10-08-2015
    Location
    Gothenburg
    MS-Off Ver
    2016
    Posts
    78

    Re: VBA Checkbox code complement

    Tried to change that but didn't do anything different. I'll post my file so you can check.

    TEST.xlsm

    Quote Originally Posted by cytop View Post
    You could try a simplistic change first:

    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Obviously, I have no idea of the data you're working with and there is a chance it will check something you do not want checked - if that happens, the only solution is to process specific checkboxes rather than all...

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: VBA Checkbox code complement

    The problem with answering questions on forums - a lot of assumptions are made.

    In your original thread, you did not mention all the other checkboxes, so I assumed there were none - the code, as written, is useless for what you want to do as it will blank all non matching checkboxes.

    Not the end of the world as the basic code can be re-written, but you need to explain the logic of what gets checked (meaning a CheckBox getting 'selected'), where and when; which checkboxes this should apply to and any other information you might think relevant.

    You know the logic, no one else does so you need to explain clearly.

  6. #6
    Registered User
    Join Date
    10-08-2015
    Location
    Gothenburg
    MS-Off Ver
    2016
    Posts
    78

    Re: VBA Checkbox code complement

    My bad Cytop. Guess I gotta be more clear to what I need help with. I'll be more specific in the future. Since I'm so "new" to all this VBA and stuff it all seem so simple to you experienced guys

    Quote Originally Posted by cytop View Post
    The problem with answering questions on forums - a lot of assumptions are made.

    In your original thread, you did not mention all the other checkboxes, so I assumed there were none - the code, as written, is useless for what you want to do as it will blank all non matching checkboxes.

    Not the end of the world as the basic code can be re-written, but you need to explain the logic of what gets checked (meaning a CheckBox getting 'selected'), where and when; which checkboxes this should apply to and any other information you might think relevant.

    You know the logic, no one else does so you need to explain clearly.

  7. #7
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: VBA Checkbox code complement

    Can we assume you only want this to work for Checkboxes in Cols B & F that contain Zon1 - 8 in the cation?

  8. #8
    Registered User
    Join Date
    10-08-2015
    Location
    Gothenburg
    MS-Off Ver
    2016
    Posts
    78

    Re: VBA Checkbox code complement

    That is correct, what this does is that when I type in a "TOWN - Cell: I19" in the cell next to "Ort - Cell:H19" it takes information from the list in sheet 3. and from the Zone cell it determine what zone it is to the checkbox. And as you wrote they work abit together, Cols B & F, just different prices (there are temporary prices in there for now). I could have changed the true/false settings to if Cols B is True so will Cols F will be, but I still want to be able to choose either of them seperatly by manually clicking the boxes.
    Quote Originally Posted by cytop View Post
    Can we assume you only want this to work for Checkboxes in Cols B & F that contain Zon1 - 8 in the cation?

  9. #9
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: VBA Checkbox code complement

    Try this then.
    Please Login or Register  to view this content.
    But I can't help feeling that Option Buttons (Which only allow 1 selection in a group) would have been a better choice for this.

  10. #10
    Registered User
    Join Date
    10-08-2015
    Location
    Gothenburg
    MS-Off Ver
    2016
    Posts
    78

    Re: VBA Checkbox code complement

    That worked like a charm Cytop! Thanks alot.

    According to option button. Do you mean that I should replace the checkboxes with option buttons instead? I'm gladly taking tips how to improve and get better in excel, so if they work differently I'll gladly exchange them to option buttons.

    Quote Originally Posted by cytop View Post
    Try this then.
    Please Login or Register  to view this content.
    But I can't help feeling that Option Buttons (Which only allow 1 selection in a group) would have been a better choice for this.

  11. #11
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: VBA Checkbox code complement

    Some of them, Probably.

    Option buttons will only allow 1 option in a group to be selected - on your worksheet, I'd assume you can only have 1 selection for Zon 1 - 8 so option buttons would be the logical choice there - but that means changes to that code .

    Probably best to just keep it in mind for the next time - it'd be a pain to replace the checkboxes now.

+ 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] Two's Complement
    By Talamon in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-19-2014, 02:52 PM
  2. [SOLVED] Checkbox to deselect another checkbox, shorter code
    By JamesT1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2013, 09:59 AM
  3. [SOLVED] VBA code to uncheck checkbox 2 & 3 if checkbox 1 is checked
    By hydz1213 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-25-2013, 03:10 AM
  4. [SOLVED] How do I change a checkbox to unchecked without running the code within the checkbox
    By jsunnb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-27-2012, 09:28 PM
  5. [SOLVED] Complement of Two Arrays
    By pratyu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2012, 07:07 AM
  6. Binary Complement
    By RK in forum Excel General
    Replies: 2
    Last Post: 08-17-2005, 07:05 PM
  7. [SOLVED] A function of reverse complement
    By M H in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 01-19-2005, 10:06 AM

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