Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Usersform in VBA for Excel

I have creted a userform using Visual basic that writes
into an excel spreadsheet. Within this form I have
several textboxes.

Is it possible for me to write some code which will
ensure that the boxes cannot be left blank when the form
is submitted and error message is presented telling the
user to add data to the relevant textboxes

Many thanks

Nick Read
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Usersform in VBA for Excel


With Textbox1
If .Text = "" Then
MsgBox "Submit data"
.SetFocus
End If
End With

--
HTH

Bob Phillips

wrote in message
...
I have creted a userform using Visual basic that writes
into an excel spreadsheet. Within this form I have
several textboxes.

Is it possible for me to write some code which will
ensure that the boxes cannot be left blank when the form
is submitted and error message is presented telling the
user to add data to the relevant textboxes

Many thanks

Nick Read



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Usersform in VBA for Excel

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If TextBox3.Text = "" Then TextBox3.SetFocus: Cancel = 1
If TextBox2.Text = "" Then TextBox2.SetFocus: Cancel = 1
If TextBox1.Text = "" Then TextBox1.SetFocus: Cancel = 1
End Sub


wrote in message ...
I have creted a userform using Visual basic that writes
into an excel spreadsheet. Within this form I have
several textboxes.

Is it possible for me to write some code which will
ensure that the boxes cannot be left blank when the form
is submitted and error message is presented telling the
user to add data to the relevant textboxes

Many thanks

Nick Read



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"