![]() |
Mandatory cell - display message
I have 2 worksheets. One is a entry page ('form') and the second a storage
for data ('database'). I have written a basic macro which enters the data from the form to the database. Howerver I would like to add to the macro and get it to check 4 cells which are mandatory. I would like it to exit out of the macro to the appropriate blank cell and display a message box to enter data. If the 4 cells have data then I would like it to continue the macro and enter data to the database sheet. Could someone please point me to a webpage with an example or explain what code I need. I have been able to get the message box to come up for the first cell but not sure how to then jump to the next mandatory one. Thanks -- Hayley |
Mandatory cell - display message
If Textbox1.Text = "" Then Msgbox "TextBox1 empty" Textbox1.SelLength = Len(TextBox1.Text) TextBox1.SelStart = 0 TextBox1.setFocus Exit Sub ElseIf Textbox2.Text = "" Then Msgbox "TextBox2 empty" Textbox2.SelLength = Len(TextBox2.Text) TextBox2.SelStart = 0 TextBox2.setFocus Exit Sub If Textbox3.Text = "" Then Msgbox "TextBox3 empty" Textbox3.SelLength = Len(TextBox3.Text) TextBox3.SelStart = 0 TextBox3.setFocus Exit Sub If Textbox4.Text = "" Then Msgbox "TextBox1 empty" Textbox4.SelLength = Len(TextBox4.Text) TextBox4.SelStart = 0 TextBox4.setFocus Exit Sub End If -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Hayley" wrote in message ... I have 2 worksheets. One is a entry page ('form') and the second a storage for data ('database'). I have written a basic macro which enters the data from the form to the database. Howerver I would like to add to the macro and get it to check 4 cells which are mandatory. I would like it to exit out of the macro to the appropriate blank cell and display a message box to enter data. If the 4 cells have data then I would like it to continue the macro and enter data to the database sheet. Could someone please point me to a webpage with an example or explain what code I need. I have been able to get the message box to come up for the first cell but not sure how to then jump to the next mandatory one. Thanks -- Hayley |
All times are GMT +1. The time now is 05:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com