ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cells Left Blank (https://www.excelbanter.com/excel-programming/399049-cells-left-blank.html)

Eric

Cells Left Blank
 
Hello all,

I am trying to make a macro that won't let you continue unless all the cells
on a particular sheet are filled in with information.

ie:
Before clicking the worksheet macro cells B9, B10, B15, etc. must contain
information. If cells B9 and B10 have info but not B15 the worksheet macro
should stop and give the message box that B15 isn't filled in.

I hope this makes sence to everyone.
Thank you in advance for all the help.

Eric


JW[_2_]

Cells Left Blank
 
To add more cirteria, just add more range addresses to the rangeArray.
Sub howAboutThis()
Dim rangeArray As Variant, r As Range
rangeArray = Array("B9", "B10", "B15")
For i = LBound(rangeArray) To UBound(rangeArray)
If IsEmpty(Range(rangeArray(i))) Then
MsgBox rangeArray(i) & " can not be blank"
Exit Sub
End If
Next i
'rest of your code here
End Sub

Eric wrote:
Hello all,

I am trying to make a macro that won't let you continue unless all the cells
on a particular sheet are filled in with information.

ie:
Before clicking the worksheet macro cells B9, B10, B15, etc. must contain
information. If cells B9 and B10 have info but not B15 the worksheet macro
should stop and give the message box that B15 isn't filled in.

I hope this makes sence to everyone.
Thank you in advance for all the help.

Eric



Eric

Cells Left Blank
 
JW,

Thank you this works but it says that cell b9 is empty and this is good now
let me through a twist into things.

What if I lable this cell would I just switch B9 for the cell name "Mix
Type". Also, when I hit okay after the msgbox tells me it's empty, it still
goes on to the next page even if the cell is blank.

Sounds like a miner fix.....

"JW" wrote:

To add more cirteria, just add more range addresses to the rangeArray.
Sub howAboutThis()
Dim rangeArray As Variant, r As Range
rangeArray = Array("B9", "B10", "B15")
For i = LBound(rangeArray) To UBound(rangeArray)
If IsEmpty(Range(rangeArray(i))) Then
MsgBox rangeArray(i) & " can not be blank"
Exit Sub
End If
Next i
'rest of your code here
End Sub

Eric wrote:
Hello all,

I am trying to make a macro that won't let you continue unless all the cells
on a particular sheet are filled in with information.

ie:
Before clicking the worksheet macro cells B9, B10, B15, etc. must contain
information. If cells B9 and B10 have info but not B15 the worksheet macro
should stop and give the message box that B15 isn't filled in.

I hope this makes sence to everyone.
Thank you in advance for all the help.

Eric




JW[_2_]

Cells Left Blank
 
I need to see the rest of your code structure in order to tell you why
it isn't exiting the code? As for the range names, yes, just replace
the B9 with the name for that range.
Eric wrote:
JW,

Thank you this works but it says that cell b9 is empty and this is good now
let me through a twist into things.

What if I lable this cell would I just switch B9 for the cell name "Mix
Type". Also, when I hit okay after the msgbox tells me it's empty, it still
goes on to the next page even if the cell is blank.

Sounds like a miner fix.....

"JW" wrote:

To add more cirteria, just add more range addresses to the rangeArray.
Sub howAboutThis()
Dim rangeArray As Variant, r As Range
rangeArray = Array("B9", "B10", "B15")
For i = LBound(rangeArray) To UBound(rangeArray)
If IsEmpty(Range(rangeArray(i))) Then
MsgBox rangeArray(i) & " can not be blank"
Exit Sub
End If
Next i
'rest of your code here
End Sub

Eric wrote:
Hello all,

I am trying to make a macro that won't let you continue unless all the cells
on a particular sheet are filled in with information.

ie:
Before clicking the worksheet macro cells B9, B10, B15, etc. must contain
information. If cells B9 and B10 have info but not B15 the worksheet macro
should stop and give the message box that B15 isn't filled in.

I hope this makes sence to everyone.
Thank you in advance for all the help.

Eric






All times are GMT +1. The time now is 04:44 AM.

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