ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What is wrong with this code? (https://www.excelbanter.com/excel-programming/342598-what-wrong-code.html)

sungen99[_32_]

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. Seem
im always getting the Checked response which means im obviously no
getting the result form the sheet correctly.

Thanks again,
Ke

--
sungen9
-----------------------------------------------------------------------
sungen99's Profile: http://www.excelforum.com/member.php...nfo&userid=914
View this thread: http://www.excelforum.com/showthread.php?threadid=47551


sungen99[_33_]

What is wrong with this code?
 

Yep. That works.

Thanks


--
sungen99
------------------------------------------------------------------------
sungen99's Profile: http://www.excelforum.com/member.php...fo&userid=9144
View this thread: http://www.excelforum.com/showthread...hreadid=475516


Gary Keramidas

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" wrote in
message ...

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




Edward Ulle

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 ***


All times are GMT +1. The time now is 03:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com