![]() |
Must be first
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 |
Must be first
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 HIS "Ronnie Coleman" wrote in message ... 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 |
Must be first
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) "Nick Hodge" wrote in message ... 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 HIS "Ronnie Coleman" wrote in message ... 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 |
Must be first
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 : 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 |
Must be first
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 "Ronnie Coleman" wrote in message ... 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 |
Must be first
Hi Nick,
I agree, that is a friendlier first touch. It still leaves the worksheet susceptible though, thus the 'also'. Bob "Nick Hodge" wrote in message ... 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 HIS "Bob Phillips" wrote in message ... 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) "Nick Hodge" wrote in message ... 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 HIS "Ronnie Coleman" wrote in message ... 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 |
All times are GMT +1. The time now is 12:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com