ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checking for non blank cells in named range (https://www.excelbanter.com/excel-programming/375062-checking-non-blank-cells-named-range.html)

Barb Reinhardt

Checking for non blank cells in named range
 
I have a range, let's call it myRange that's cells B22:B24 in my worksheet.
I need to check that these cells are all not blank before doing something
else. I'm not sure how to write the code to check that all are non-blank.
Any suggestions?

Thanks

Sandy

Checking for non blank cells in named range
 
Here you go

Sub FindBlank()
Dim MyRange, mcell As Range
'Set your range to whatever you want
Set MyRange = Range("B22:B24")
For Each mcell In MyRange
If mcell.Value = Empty Then
MsgBox "You have blank cells in Range - " _
& MyRange.Address(False, False)
Exit Sub
End If
Next
MsgBox "You have NO blank cells in Range - " _
& MyRange.Address(False, False)
' the rest of your code here
End Sub


Sandy

Barb Reinhardt wrote:
I have a range, let's call it myRange that's cells B22:B24 in my worksheet.
I need to check that these cells are all not blank before doing something
else. I'm not sure how to write the code to check that all are non-blank.
Any suggestions?

Thanks




All times are GMT +1. The time now is 05:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com