Must be first

  • Thread starter Thread starter Ronnie Coleman
  • Start date Start date
R

Ronnie Coleman

I need someone entering information to a worksheet to
enter into a specific cell first. It must be the first
thing they do so is there a way to code a message box
which would pop up to say "you must enter a value in A1
before anywhere else" if they try and enter anywhere else?

Thanks
 
Ronnie

You could put code in the Workbook_Open() event like so

Private Sub Workbook_Open()
MsgBox "You must enter data in Cell A1 first", vbOKOnly + vbQuestion
Worksheets("Sheet1").Activate
Range("A1").Select
End Sub

It fires when the workbook is open, displays a msgbox, activates sheet1 and
selects A1 on that sheet

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
You would also need to trap input on the sheet to ensure A1 is completed
before allowing anything else, using the Change event.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Hi

Insert in the sheet module

Private Sub worksheet_Activate()

Range("A1").Activate

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Application.EnableEvents = False

If Target.Address = Range("A1").Address Then
Else
If IsEmpty(Cells(1, 1)) Then
MsgBox "you must enter something in A1 before anything else"
Range("A1").Activate
End If
End If

Application.EnableEvents = True

End Sub


So long

Ronnie Coleman a écrit :
 
Bob

I felt that at first to, it's just with the msgbox it seemed a little more
informative than that, hence I used vbInformation for example

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
Ronnie,

You may also want to consider an InputBox or a UserForm which would pop up
as the workbook opens and would prompt the user to enter the value, othrwise
close the book.

Regards,
KL
 
Hi Nick,

I agree, that is a friendlier first touch. It still leaves the worksheet
susceptible though, thus the 'also'.

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top