+ Reply to Thread
Results 1 to 3 of 3

VBA checkbox code

  1. #1
    Forum Contributor
    Join Date
    05-09-2005
    Location
    SC
    Posts
    196

    VBA checkbox code

    What is wrong with this code?

    Private Sub Checkbox1_Click()
    Userform1.Checkbox1.Value = True
    Range ("A2").Value = True
    Userform1.Checkbox1.Value = False
    Range ("A2").Value = False


    With this code if I check the check box I can see both true and falserun in the cell, then it ends up on false. And there is no check in the both - like it's cancelling itself out.

    I want to check the box to return true in a call, uncheck to return false.

    Help

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

    The code is doing exactly what you told it to do. Set the the CheckBox True and then set the Checkbox False. What you want to do is If the checkbox is already True then have A2 equal True and vice versa. You need to test the current state of the CheckBox to return the proper value to A2.

    Please Login or Register  to view this content.


    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    05-09-2005
    Location
    SC
    Posts
    196

    Checkbox code

    Thanks Leith,

    I'll study my code & this one, then try it out.

+ 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