LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Need help developing a Excel VBA Macro to Vaildate data entered intoa textbox

I am collecting data from users in a Excel spreadsheet. To ensure all
the required fields are filled out, I have created a userform that
loads on opening of the spread sheet.

Currently there are three Textboxes a command button writes the data
to the sheet and highlights in pink any not filledout.

I need a higher level of data vaildation on the two other text boxes.

Textbox2 must contain an email address (checking for hyperlinked
content is probably the easiest way to vaildate for this)

Textbox3 must contain only a 9 digit numerical number

Option Explicit
Dim y As Long
Const pink = 16761855
Private Sub CommandButton1_Click()
Dim EmptyBoxes As Integer
EmptyBoxes = EmptyBoxes + check(TextBox1)
EmptyBoxes = EmptyBoxes + check(TextBox2)
EmptyBoxes = EmptyBoxes + check(TextBox3)
If EmptyBoxes = 0 Then
ActiveWorkbook.Save
Unload Me
End If
End Sub
Function check(tb As Control)
Dim res As Integer
res = 0
If tb.Text = vbNullString Then
res = 1
tb.BackColor = pink
Else
Cells(y, CLng(Right(tb.Name, 1))) = tb
End If
check = res
End Function
Private Sub UserForm_Activate()
y = [A1].End(xlDown).Row + 1
End Sub
 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a Macro in Excel 2004 to move entered data from one sheet toanother and space between rows when next data is entered? [email protected] Excel Programming 1 June 4th 08 05:08 PM
Developing a macro that will help with mass address cleansing Jordan Excel Programming 1 March 7th 08 02:24 AM
interaction with excel and ms SQL (retrieval of records from sql intoa sheet) [email protected] Excel Programming 2 March 5th 08 12:24 PM
Request for Help in Developing a Macro for a Billing Application Steve Excel Programming 10 February 28th 08 10:06 PM
macro that takes data entered in a user form textbox to go to a ra BrianMo Excel Programming 5 September 22nd 06 03:52 PM


All times are GMT +1. The time now is 02:48 PM.

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

About Us

"It's about Microsoft Excel"