+ Reply to Thread
Results 1 to 5 of 5

What is wrong with this code?

  1. #1
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    What is wrong with this code?

    Sub Macro1()

    Sheets("Sheet1").Select
    If Range("H20").Select = "FALSE" Then
    MsgBox "NOT CHECKED"
    Else
    MsgBox "CHECKED"
    End If

    End Sub



    H20 contains the result of a checkbox of either a False or True. Seems im always getting the Checked response which means im obviously not getting the result form the sheet correctly.

    Thanks again,
    Ken

  2. #2
    Registered User
    Join Date
    05-06-2004
    Posts
    60
    Hi sungen99,

    try this:

    Sheets("Sheet1").Select
    If Range("H20").Text = "FALSE" Then
    MsgBox "NOT CHECKED"
    Else
    MsgBox "CHECKED"
    End If

    End Sub

    Oreg

  3. #3
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651
    Yep. That works.

    Thanks

  4. #4
    Gary Keramidas
    Guest

    Re: What is wrong with this code?

    or this, no need to select anything:

    Sub Macro1()

    If Sheets("Sheet1").Range("H20").Text = "FALSE" Then
    MsgBox "NOT CHECKED"
    Else
    MsgBox "CHECKED"
    End If

    End Sub

    --


    Gary


    "sungen99" <sungen99.1wswmg_1129140330.0367@excelforum-nospam.com> wrote in
    message news:sungen99.1wswmg_1129140330.0367@excelforum-nospam.com...
    >
    > Sub Macro1()
    >
    > Sheets("Sheet1").Select
    > If Range("H20").Select = "FALSE" Then
    > MsgBox "NOT CHECKED"
    > Else
    > MsgBox "CHECKED"
    > End If
    >
    > End Sub
    >
    >
    >
    > H20 contains the result of a checkbox of either a False or True. Seems
    > im always getting the Checked response which means im obviously not
    > getting the result form the sheet correctly.
    >
    > Thanks again,
    > Ken
    >
    >
    > --
    > sungen99
    > ------------------------------------------------------------------------
    > sungen99's Profile:
    > http://www.excelforum.com/member.php...fo&userid=9144
    > View this thread: http://www.excelforum.com/showthread...hreadid=475516
    >




  5. #5
    Edward Ulle
    Guest

    Re: What is wrong with this code?


    Even simpler. Since the data source of a checkbox is a boolean value
    this will work.

    Sub Macro1()

    If Sheets("Sheet1").Range("H20") Then
    MsgBox "Checked"
    Else
    MsgBox "Not Checked"
    End If

    End Sub



    *** Sent via Developersdex http://www.developersdex.com ***

+ 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