Worksheet check macro sub-routine

DenniBrink

New Member
Joined
Jul 31, 2016
Messages
46
;) Greetings! I searching for assistance in writing a VBA macro that will check each cell in a range for the existence of a specific text string "Mismatch". If the text string exists a Msgbox "Mismatch Found!"; if not Msgbox "Worksheet Checks Good!" would appear.

Worksheet: CREW30
Range: B4: I65
 

Some videos you may like

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,762
Office Version
2013
Platform
Windows
Try this:
Code:
Sub Search_For_Mismatch()
Dim c As Range
    For Each c In Range("B4:I65")
        If c.Value = "Mismatch" Then MsgBox "Mismatch Found!": Exit Sub
    Next
    MsgBox "Worksheet Checks Good!"
    End Sub
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,641
My Answer Is This's code should work.

Perhaps adding a sheet qualification
Code:
For Each c In Worksheets("CREW30").Range("B4:I65")
Also the test in that code is case sensitive.

"Does not work" is a bit vague. What does MyAnswer's code do in your workbook? Does it return nothing or does it return incorrect results or...
 
Last edited:

DenniBrink

New Member
Joined
Jul 31, 2016
Messages
46
My mistake! Sorry about that. The text string "MISMATCH" is case sensitive. The VBS script now works.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,695
Messages
5,488,341
Members
407,634
Latest member
ps01

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top