[VBA] Find particular value in range

StupidCoffee

New Member
Joined
Jun 11, 2013
Messages
16
Using Microsoft Excel 2007, VBA

I am trying to display an error message if a range is missing '0' or '100', or is empty.

I figured out how to display error when the selected range is empty, but I cannot figure out how to find if a particular value exists within a range and return an error if there isn't.

Please help


Thanks.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
one way is to use a COUNTIF in the VBA code, if the count is 0 then the value doesn't exist in the range like
Code:
if Application.WorksheetFunction.Countif("yourrange","0")=0 then
    msgbox "Value doesn't exist"
End if

There's also the
Code:
range.find
option
 
Upvote 0

Forum statistics

Threads
1,216,109
Messages
6,128,875
Members
449,476
Latest member
pranjal9

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