View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
unplugs[_8_] unplugs[_8_] is offline
external usenet poster
 
Posts: 1
Default How to do validation ???

I face a problem in validation. How to do the validation whe
programming in VBA? I had do the validation to request user fo
entries. Anyway, I don't know how to do for the following features:
1) For Project Name, it must be enter like this: ?##-####

? = alphabet
#= integer

2) For Hours Spent, it must be enter integer only, and not alphabet o
other sign.

Below is my code:



Private Sub SubmitButton_Click()

Range("C3") = " Project Name "
Range("D3") = " Project Element "
Range("E3") = " Hours Spent "

Sheets("Sheet1").Activate
NextRow = Application.WorksheetFunction.CountA(Range("A:A")) + 4


If TextProjectName.Text = "" Then
MsgBox "You must enter your project name."
Exit Sub
End If

If TextProjectElement.Text = "" Then
MsgBox "You must emter your project element."
Exit Sub
End If

If TextHoursSpent.Value = "" Then
MsgBox "You must enter your hours spent."
Exit Sub
End If

Cells(NextRow, 3) = TextProjectName.Text
Cells(NextRow, 4) = TextProjectElement.Text
Cells(NextRow, 5) = TextHoursSpent.Value

TextProjectName.Text = ""
TextProjectElement.Text = ""
TextHoursSpent.Value = ""

TextProjectName.SetFocus

End Sub




Thousands thanks to anyone that can help me on this matter.
:)

Thanks

--
Message posted from http://www.ExcelForum.com