View Single Post
  #2   Report Post  
jack_n_bub jack_n_bub is offline
Member
 
Location: Bangalore
Posts: 41
Default

Quote:
Originally Posted by Bakar View Post
Hi Everyone
can someone help please
let say I have in Sheet 1 in cells CW 24 =yes,CW 25 =yes,CW 26 =yes,CW 27 =yes,CW 28 =yes
If all thes cells are yes I want a macro to give me a message box "Successfully completed!"

Thnxs for your valuable help
Bakar
Hi,

Try this code.

Sub Check()
Dim Rng As Range
Set Rng = Range("CW24:CW28")
If Application.WorksheetFunction.CountIf(Rng, "<Yes") = 0 Then
MsgBox "All cells contain YES", vbInformation
Else
MsgBox "One of the cells doesn't contain YES", vbInformation
End If
End Sub

Just a suggestion. You should try to give the range a meaningful name such as SearchRange or something. Also, are you going to run this macro on your own or should it run with an event such as changing the CW24:CW28 range?

I hope this helps you.

Prashant