MsgBox for unmet conditions (?)

Soozie

New Member
Joined
Feb 18, 2002
Messages
13
Hey! I'm looking for a way to have a message box appear when a person tries to email, save and/or print a worksheet AND they haven't filled in all required fields. The fields are scattered throughout the sheet (ie: A1,B50,C12)
PLEASE help. This is driving me nuts.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Save and Print are "easy", but Email... that's a complicated one. I feel that the easy way out would be to replace the current menus with your own, and test, when they are run, if they have filled the info.

To do Save and Print you use the Workbook events, BeforeSave and BeforePrint


_________________
Regards,

Juan Pablo G.
MrExcel.com Consulting
This message was edited by Juan Pablo G. on 2002-02-20 11:54
 
Upvote 0
Ok. I thought I could keep up but quite obviously I'm a novice. Can you give me a specific...in other words could I beg you enough to actually spell it out for me? I'd be grateful forever.
 
Upvote 0
Ok, let's take it step by step then.

First, create this function in a module

Function Validate() as Boolean
Dim Rng as Range
Dim Cll as Range

Validate = True 'This is the default
Set Rng = Union(Range("A1"),Range("B50"),Range("C12"))

For each Cll in Rng
If Len(Cll) = 0 then 'Cell is Empty
Validate = False
Exit Function
End If
Next Cll
End Function

And in your code you can use it like this:

Sub Test()
If Not Validate Then MsgBox ("Hey !, FILL ME UP")
End Sub

This is the first step. Tell me when you have it completed.

_________________
Regards,

Juan Pablo G.
MrExcel.com Consulting
This message was edited by Juan Pablo G. on 2002-02-20 11:59
 
Upvote 0
Ok, now right click on the little workbook icon near the "File" menu, and select view code. That should take you to the VB Editor.

Put this there.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Not Validate Then
MsgBox "Hey, FILL ME UP !"
Cancel = True
End If
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Not Validate Then
MsgBox "Hey, FILL ME UP !"
Cancel = True
End If
End Sub

That way, the user will not be able to Save or Print unless they fill the values.
 
Upvote 0

Forum statistics

Threads
1,214,559
Messages
6,120,208
Members
448,951
Latest member
jennlynn

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