Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Form

Status
Not open for further replies.

vextax21

Programmer
Jun 12, 2003
4
CA
Hi, I have a user form with a few textboxes. I want to know if there is a way to affect a value to all the text box at the same time. Lets say I want to initialise the textboxes with blank. D I have to go put blank in every textbox?.


Another question I have is while validating the data entered inside these textboxes is there a way to verify all the textboxes at the same time for a numeric value instead of checking them one by one?

Thx in advance
 
1. My understanding is that Excel does not allow all of the text boxes to be treated as a collection/group.
I have seen groups of controls processed in bulk however by looping through all controls and checking for specific strings in the control names.

ie for each cntl in me.controls
if left(cntl.name, 2) = 'tb' then
cntl.value = " "
end if
next

2. Try the following :
'If you use the following code any character other than a number, will NOT be accepted by the text box.
Private Sub tbName_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 48 To 57
KeyAscii = KeyAscii
Case Else
KeyAscii = 0
End Select
End Sub

I cannot remember where I got this code from.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top