find empty cell from specific cell ranges and display result in msg box.

ebineg

New Member
Joined
Feb 24, 2016
Messages
39
Hi,

i have a case where i wanted to find if there is any empty cells in the specific range of cells. if the macro find any empty cell it should show the cell names in message box or the empty cell can be highlighted, if there is no empty cell then"NO EMPTY CELLS FOUND" should be displayed in msg box.Could anyone help me with this vba code?

My selective ranges are

G13:G32
G35:G54
G57:G76
G79:G98

Thanks in advance.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Try this:
Code:
Sub FindBlanks()
    
    Dim myRange As Range
    Dim cell As Range
    Dim myString As String
    
'   Set range to check
    Set myRange = Range("G13:G32, G35:G54, G57:G76, G79:G98")
    
'   Check all cells
    For Each cell In myRange
        If cell = "" Then
            myString = myString & cell.Address(0, 0) & ","
        End If
    Next cell
    
'   Return message box
    If Len(myString) = 0 Then
        MsgBox "NO EMPTY CELLS FOUND"
    Else
        MsgBox "Empty cells found in following cells:" & vbCrLf & Left(myString, Len(myString) - 1)
    End If
    
End Sub
 
Upvote 0
Note. A simple non-VBA solution that may work for you is to simply use Conditional Formatting to highlight the blank cells in your designated ranges.
The main advantage there is it is automatic and you do not need to run anything.
 
Upvote 0

Forum statistics

Threads
1,214,865
Messages
6,121,988
Members
449,060
Latest member
mtsheetz

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