Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50090

UserForm Assign Roll Number to Different Classes

$
0
0
Hello EveryOne!


In my UserForm I have got a ComboBox which have different Classes name( for example Class 1 , Class 2 , Class 3 .........Class 10 )

In the UserForm I have a Text Box to manually assign "Roll Number" to Students ( making sure not assigning a Single Roll Number to two different students in a Class)

I want when I select any class from UserForm comboBox..the roll numbers should not repeat in a Class and every Class Roll number should start form "1"

I used the following code which just look not repeating Roll Number... but it does not look that which class is Selected from comboBox.

For example...In class 1 there are Three Studetns and there roll number will be 1, 2, 3

In class 2 there are two students and there roll number will be 1 & 2

(Roll Number column = "B" ". and Class column = " D" )

but the code below just look to not repeat the roll number and it dispalys roll number for Class 1 & Class 2 like this ( 1,2,3,4,5)


Code:

If WorksheetFunction.CountIf(Sheet1.Range("B2:500"), TextBoxRollNo.Text) <> 0 Then
 MsgBox "This Roll Number has been already used", vbCritical
 Exit Sub
 End If


Please Help.....!
Attached Files

Viewing all articles
Browse latest Browse all 50090

Trending Articles