If range contains an empty cell, display msgbox & exit s

Berko

Board Regular
Joined
Oct 13, 2005
Messages
64
I have the following code in the middle of a routine. What I want is for it to check each cell in a range and if there is an empty one, bring up the message box and then stop executing code. It seems to bypass this whole bit entirely.
Code:
        EmptyPaid = 0
        For i = 1 To EndSumR - BeginSumR
            If ActiveCell.Value = "" Then
                EmptyPaid = EmptyPaid + 1
            End If
        ActiveCell.Offset(1, 0).Select
        Exit For
        Next i
        If EmptyPaid > 0 Then
            MsgBox ("There is an empty cell in the Paid column for this deposit." & Chr(13) & "Please correct and try again.")
            Exit Sub
        Else
        [continue with the rest of the routine]
The check can't be done any earlier than this because before this is where I figure out the range that I need to check for empty cells. Zero value is OK, I just need to make sure that there is something in every cell in the range.
 
Hello, McFly!!!

I found the answer in another post. I had the sheet protected.
Code:
Sheets("Sheet1").Unprotect
ActiveCell.Font.Bold = True
Sheets("Sheet1").Protect
This fixed it right up.
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,215,748
Messages
6,126,654
Members
449,326
Latest member
asp123

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