Person cannot go further unless certain cells filled out.

  • Thread starter Thread starter Paula
  • Start date Start date
P

Paula

I am making a calendar linked to expense report for eahc person in complany.
I want to make it impossible to go further if they do not complete their
name, title and Initials. How do I do this?
Thanks.
 
Let's assume the the name, title, and initials are in cells A1 thru A3.
Insert the following worksheet event macro:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set r = Range("A1:A3")
Set r1 = Range("A1")
Set r2 = Range("A2")
Set r3 = Range("A3")
If Intersect(r, Target) Is Nothing Then
If IsEmpty(r1.Value) Or IsEmpty(r2.Value) Or IsEmpty(r3.Value) Then
MsgBox ("put your stuff in")
Application.EnableEvents = False
r1.Select
Application.EnableEvents = True
End If
End If
End Sub
 
I don't mean to reveal the fact I am an idiot, but when I go to record the
macro (I changed the appropriate cells and message), I get a message that I
am doing something wrong. There is a yellow arrow on very first space with
sub blah blah written in it. I have 2007, and am not sure of the format of
macros. Is the first line of your macro the sub line? Then it asks about the
last line end sub. I need exact directions on how to place this in the macro
editing box. Thanks so much for your swift response!
 
Begin by completely removing our first attempt and then:


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm
 
It worked! Thank you Gary, you are my hero!

Gary''s Student said:
Begin by completely removing our first attempt and then:


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm
 
Back
Top