Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force mandatory input into cell

Status
Not open for further replies.

LBryant777

IS-IT--Management
Mar 24, 2004
23
US
I am working on a workbook and I want to use an checkbox control to be checked off on each sheet when the worksheet is completed. However, there is one merged cell (d15 -k15) on each sheet that needs to be filled in with text before the sheet can be considered complete. I tried using this code attached to an ActiveX control checkbox:

Private Sub CheckBox1_Click()
Range("a1").Activate
If IsEmpty(D15) Then
MsgBox "Complete the Comments Field."
CheckBox1.Value = False
Else
CheckBox1.Value = True
End If
End Sub

However, regardless of whether the field has text or is empty, I still get the text box. Also, I have to click the OK in the message box twice - first time when it checks the cell and the second time when it clears the cell that holds the value of the checkbox. Can someone help me? Thanks!
 
Have you read the help for the IsEmpty function?

Try:

if Range("D1").value = "" then
 
I did read the information on the IsEmpty Function, however I apparently misinterpreted how it should be used. My mistake.

I decided to change from using an ActiveX checkbox to using the checkbox from the Forms toolbar as I don't need all of the functionality of an ActiveX object. I copied the code above into a macro (with your revision) and attached it to the checkbox. Works great. Just one other issue: if there are comments in the required field and I check the Completed box, it will not let me uncheck the checkbox as long as there is text in the required cell. Could you help me with that small modification in my code? This is what my code looks like now:

Sub CheckBox2_Click()
Range("a1").Activate
If Range("D25").Value = "" Then
MsgBox "Complete the Comments Field."
Range("AA2").Value = False
Else
Range("AA2").Value = True
End If
End Sub

Thanks in advance for your help!
 
Change your sub to look like:
Code:
Sub CheckBox2_Click()
Range("a1").Activate
    If Range("D25").Value = "" Then
        MsgBox "Complete the Comments Field."
        Range("AA2").Value = False
    End If
End Sub


Regards,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top