![]() |
How to force data entry with error messages
I posted a question earlier this week about how to force a user to enter data
in a cell. Gary''s Student - gsnu200775 provided the following reply: "Put the following line in a standard module: Public checkit As Boolean Put the following worksheet event macro in the worksheet code area: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Set b9 = Range("B9") Set t = Target If Intersect(t, b9) Is Nothing Then If checkit Then If b9.Value = "" Then Application.EnableEvents = False b9.Select Application.EnableEvents = True Else checkit = False End If End If Else checkit = True End If End Sub" Which works beautifully!! Thank you Gary. However I have two more questions: 1. How do I change the code to provide an error message to the user that they have to enter data in the cell 2. How do I change the range so that I can say force data entry for all column 'B' cells from row 9 - row 50. Any help would be greatly appreciated!!! Cindy Butler |
How to force data entry with error messages
Okay -
I have answered question 1. I still need some help with question 2: 2. How do I change the range so that I can say force data entry for all column 'B' cells from row 9 - row 50. Thanks - Cindy "CindyB" wrote: I posted a question earlier this week about how to force a user to enter data in a cell. Gary''s Student - gsnu200775 provided the following reply: "Put the following line in a standard module: Public checkit As Boolean Put the following worksheet event macro in the worksheet code area: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Set b9 = Range("B9") Set t = Target If Intersect(t, b9) Is Nothing Then If checkit Then If b9.Value = "" Then Application.EnableEvents = False b9.Select Application.EnableEvents = True Else checkit = False End If End If Else checkit = True End If End Sub" Which works beautifully!! Thank you Gary. However I have two more questions: 1. How do I change the code to provide an error message to the user that they have to enter data in the cell 2. How do I change the range so that I can say force data entry for all column 'B' cells from row 9 - row 50. Any help would be greatly appreciated!!! Cindy Butler |
All times are GMT +1. The time now is 10:07 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com