If it need not be a checkbox, you can do it with formulas very easily.

Format column 3 to be center aligned and put in this formula:

=IF(ISBLANK(A1),IF(ISBLANK(B1),"","X"),"X") (assuming your first two columns
are A1 and B1... you can adjust references as needed but this will easily
copy and paste into other cells)

Then no messy checkboxes or complex code to try and find a checkbox which is
contained in that row (plus you can then filter for the X's and all kinds of
stuff). This does get complicated quickly if you want to eliminate blank
spaces (" ") or certain strings, but then you could write a custom function
to test for the blanks:

=MyBlankCheck(A1,B1) in your cell to check

Insert this code into a module in your VBA project:

Public Function MyBlankCheck( oFirstCell as Excel.Range, oSecondCell as
Excel.Range )
        Dim strResult as String, strFirstCell as String, strSecondCell as
String

        strFirstCell = oFirstCell.Value
        strSecondCell = oSecondCell.Value

        strResult = "X"

        If strFirstCell = "" AND strSecondCell = "" Then 'Values were blank,
return nothing
                strResult = ""
        End If

        If strFirstCell = " " OR strSecondCell = " " Then 'Values were
present but blank spaces, return nothing
                strResult = ""
        End If

        If strFirstCell = "<anything else you want to check for>" or
strSecondCell  = "<anything else you want to check for>" Then 'Values
matched some other criteria to be ignored
                strResult = ""
        End If

        MyBlankCheck = strResult
End Function

-----Original Message-----
From: excel-macros@googlegroups.com [mailto:excel-mac...@googlegroups.com]
On Behalf Of wilz
Sent: Friday, February 27, 2009 6:22 AM
To: MS EXCEL AND VBA MACROS
Subject: $$Excel-Macros$$ complete checkbox automatically


Newbie question:

I have a worksheet with three columns and multiple rows

When column 1 and column 2 have entries (i.e., the cells are no longer
blank), I want a checkbox in column 3 to be automatically checked

In this manner, I can tell which rows need my attention

Is there anyway to do this with VBA?

thanks in advance, wilz



--~--~---------~--~----~------------~-------~--~----~
-------------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
-------------------------------------------------------------------------------------
-~----------~----~----~----~------~----~------~--~---

Reply via email to