mandatory filling

N

Noctos

Hey do any of you guys know if it is possible to make sure all cells are
filled in before any macro or a specific macro is allowed to initiate
i.e. all cells in a form should be filled in before the button with a
macro to move to the next sheet is allowed to initiate.
 
D

Dave Peterson

If you give the range of cells that must be filled in, you can add something
like this to the top of your "move to next sheet" macro:

Option Explicit
Sub testme()

With Worksheets("sheet1").Range("mustbefilledin")
If .Cells.Count <> Application.CountA(.Cells) Then
MsgBox "Nope--fill in the range"
Exit Sub
End If
End With

'continue with your code

End Sub
 
N

Noctos

hey thanks for the help the only tricky bit is selecting the cells since
they are scattered in several place so i wouldn't be able to use the
range function. Is there a way i could select these cells and name them
under one group even though they are scattered so the code would know
which cells need to contain data. thanks
 
G

Gord Dibben

Noctos

Select the cells by using CRTL + Click then Insert>Name>Define.

Refer to that named range in the line

With Worksheets("sheet1").Range("mustbefilledin") where "mustbefilledin" is
the named range.

Gord Dibben Excel MVP
 
Top