Checking for a range of values in a if statement

Slade2000

Board Regular
Joined
Feb 3, 2009
Messages
118
Hi

I would like to know how can i check for a rabge of cells that contain something in a if function. This is the code i tried but does not seem to work?

If i use it with single cell and not a range it works 100%

Code:
    If Range("C5").Value < Range("A2").Value Then
        If Range("K5:K11") = "" Then
         MsgBox "Werk"
        End If
    End If
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Re: Checking for a range of values in a if statement [Solved]

Got it.

Code:
Sub Email()
    Dim A As Integer
    A = Application.WorksheetFunction.CountIf(Range("K5:K11"), "")
    If A > 0 Then
     MsgBox "Werk"
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,140
Messages
6,053,727
Members
444,681
Latest member
Nadzri Hassan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top