+ Reply to Thread
Results 1 to 9 of 9

how to fetch data from a table on check event of a checkbox in excel vba

  1. #1
    Registered User
    Join Date
    03-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    24

    how to fetch data from a table on check event of a checkbox in excel vba

    Hi Guys,

    I am having issues while running a script which actually checks in a worksheet for the checkboxes set to true. I am trying to run a loop which will get these checkboxes (checked) and store their caption in an array. Then I want to search another worksheet/table with that caption.

    The code snippet i tried is mentioned below. This code is just checking for the caption values are getting retrieved or not:
    Please Login or Register  to view this content.
    All the excel gurus out thr plzz help.
    Last edited by Leith Ross; 04-27-2013 at 05:58 AM. Reason: Added Code Tags

  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,258

    Re: how to fetch data from a table on check event of a checkbox in excel vba

    Hello basubdd,

    Try this code...
    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!)

  3. #3
    Registered User
    Join Date
    03-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: how to fetch data from a table on check event of a checkbox in excel vba

    Thanks a lot Leith.

    The code works now. But if you don't mind I also wanna know what was wrong with my code actually ...

    Regards
    Basu

  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: how to fetch data from a table on check event of a checkbox in excel vba

    Hello basubdd,

    Glad you asked that question. You won't find this information in the books. The Forms Checkbox control can be controlled in 3 ways: Manually clicking it, Using a Linked Cell, or by Code. Manually will not be discussed.

    The Checkbox control will respond to a Linked Cell when the cell's value is either a Boolean True or False. It would make sense the same would hold true for controlling it by code. But, this is Microsoft we are talking about.

    When setting the Forms Checkbox to checked or clear state using code, there are 2 constants used for this purpose: xlOn and xlOff. The values are actually 1 and -4146, respectively. These values are not the same as the VBA Boolean values of -1 and 0. This why your code fails.

  5. #5
    Registered User
    Join Date
    03-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: how to fetch data from a table on check event of a checkbox in excel vba

    Thanks a lot Leith for this valuable explanation.

    Technically, you mean to say that

    chk.Value = xlOn or chk.Value = 1 are the same and they both will work.

  6. #6
    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: how to fetch data from a table on check event of a checkbox in excel vba

    Hello basubdd,

    That is correct.

  7. #7
    Registered User
    Join Date
    03-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: how to fetch data from a table on check event of a checkbox in excel vba

    Hi Leith,

    Can you help me out with my other post
    " Error in Displaying data fetched from a table "

    This is actually a continuation of my task after what you have suggested.

    Regards
    Basu

  8. #8
    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: how to fetch data from a table on check event of a checkbox in excel vba

    Hello basubdd,

    It appears another member has been helping you successfully with this post. My help at thsi point would be redundant.

  9. #9
    Registered User
    Join Date
    03-30-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: how to fetch data from a table on check event of a checkbox in excel vba

    Hi Leith,

    Yep, I got the solution for that as wel.

    Thanks anyways!!!

+ 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