How to know if no coincidence found?

ColdGeorge

Active Member
Joined
Aug 21, 2012
Messages
407
Office Version
  1. 2016
Platform
  1. Windows
Hi all

VBA Code:
Dim Cell As Range
For Each Cell In Range("E5:E24")   
    If Cell.Value = Date Then
        MsgBox "Coincidence found"
    End If   
    Next

This simple code works fine, my question is: how should I amendment it to know when there is not a coincidence?

Thanks, ColdGeorge
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Maybe
VBA Code:
   Dim Cell As Range
   For Each Cell In Range("E5:E24")
      If Cell.Value = Date Then
          MsgBox "Coincidence found"
          Exit Sub
      End If
      MsgBox "Not found"
   Next
 
Upvote 0
Hi Fluff

Thanks for your quick response. But I have to hit the MsgBox button for each record in range. Is there a better way to do this?

ColdGeorge
 
Upvote 0
Oops, the 2nd msgbox should go after the Next not before.
 
Upvote 0
Solution
Fluff

Now I'm a happy camper. Everything is under control. Thanks.

ColdGeorge
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

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