Link to home
Start Free TrialLog in
Avatar of Andreas Hermle
Andreas HermleFlag for Germany

asked on

check whether a range of cells contains a certain value using VBA

Dear Experts:

I got a form with Active X Control boxes.

In the below code only Range("F23") is checked whether it contains the boolean value 'False'.

I would like to expand the IF statement so that Range "F23" to Range "F30" is included, i.e. the IF statement is true
 if any number of Cells (1 to 8) in the range "F23" to "F30" has the boolean value of 'False'.

Help is very much appreciated. Thank you very much in advance.

Regards, Andreas

Sub Check_for_value_in_a_range()

If ActiveSheet.OLEObjects("chbx_GenSurg").Object.Value = True And ActiveSheet.Range("F23").Value = False Then
ActiveSheet.OLEObjects("chbx_GenSurg").Object.Value = False

End If

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Andreas Hermle

ASKER

Hi Aikimar, thank you very much for your swift and professional response. For me as an amateur in VBA this concise solution looks 'strange' but it seems to work. will do some more testing and then let you know

Regards, Andreas
Great job, thank you very much. Will shortly post a similiar question.

Regards, Andreas