Userform Validation and Entry For: Next

d-alan

Board Regular
Joined
Mar 26, 2002
Messages
119
Here is a three part question that i am convinced will use the practically the same code, but I cannot fiqure the coreect syntax. I have been trying for:next combinations, anyways.

1. I have 13 textboxes in a userform that are named uni, uni2, uni3, uni4, etc... On the enter event in to the textbox I want that textbox to show the text =Each.
I have this code that works fine, however i have it thirteen times.
Private Sub uni13_enter()
uni13.Text = "Each"
End Sub


2. I think you get the drift, here I have thirteen textboxes that update totalt texbox on change. Again thirteen lines of codes just to rename from uprice, uprice1, uprice2, uprice3 etc....
Private Sub uprice_Change()
On Error Resume Next
total = uprice * quan
Totalt = Val(total.Text) + Val(total2.Text) + Val(total3.Text) + Val(total4.Text) + Val(Total5.Text) + Val(Total6.Text) + Val(Total7.Text) + Val(Total8.Text) + Val(Total9.Text) + Val(Total10.Text) + Val(total11.Text) + Val(Total12.Text) + Val(Total13.Text)
On Error Resume Next
End Sub
3. Still on the same userform, but a little different question, (same formula I think).
I have 13 comboboxes named modes, modes2, modes3, modes4 etc....
What code can I use to check to make sure that none of the comboboxes contain the same value.
if modes = modes2 then
msgbox YOU CANNOT ENTER THE SAME VALUE.

This userform has 104 textboxes, and 39 comboxes not to mention optionbuttons and commandbuttons. The code is just become to large to work with.
On a bright note it does all work except for question number 3.
Any help would be appreciated.
Thanks
-D
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Thanks Dave,

But I think I have bitten off too much in this one. If I would have just wriiten the longhand code for question three I would be done already. But now I want to fiqure this out.
This is the code i have put together for checking to make sure there are not duplicate entries.(?#3)

Dim i As Integer
For i = 2 To 14
'Although 13 boxes I used fourteen because at some point it was looking at thirteen in both values.

J = Controls("modes" & i)
On Error Resume Next
k = Controls("modes" & i + 1)
If k = J Then
MsgBox (k) & " Is a Double Entry Please Adjust Entry"
End If
'Since modes +(i) always is a number I just through in this code to check first entry.
If sales2.modes = J Then
MsgBox (J) & " Is a Double Entry Please Adjust Entry"
End If
Next i

The problem here is that it will only look at consecutive entries. If there is the same entry in 'box2 and 'box7 it does not find it.

Suggestions?
 
Upvote 0
This is what i came up with for checking the values of comboboxes, listboxes, etc with same name plus differing value.(ie modes2, modes3, modes4, modes5)

Dim i As Integer
For i = 2 To 12
J = Controls("modes" & i)

For r = 3 To 13
K = Controls("modes" & r)
If K<> "" Then
If i<> r Then
If J = K Then
MsgBox (K) & " IS ENTERED TWICE ON LINE " & (r) & " AND ON LINE " & (i) & _
". PLEASE ADJUST ENTRIES. "
Exit Sub
End If
End If
End If
Next r

If J<> "" Then
If sales2.modes = J Then
MsgBox (J) & " IS ENTERED TWICE ON LINE 1" & " AND ON LINE " & (i) & _
". PLEASE ADJUST ENTRIES. "
Exit Sub
End If
End If

Next i
This message was edited by d-alan on 2002-04-03 07:35
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,254
Members
448,879
Latest member
oksanana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top