Hello,
I have a userform "PC" to manage the PCs usage and timing
I have 8 PCs in each room, sometimes each one (or some of them) used for different type/time... and sometimes all of them for the same type/time...
In the userform "PC" I have the following controls
1- Combo Box "cmb_Num" (List from 1 to 8, to determine the number of users)
2- Text Boxes "txt_Name1 / txt_Name2 / txt_Name3.... until 8" (to fill the user's names)
3- Combo Box "cmb_Type" (list of usage types: research, Data Entry, Printing...)
4- Text Box "txt_Time" (to determine how long the user will use the PC: 30 Min, 1 Hour...)
5- There are many other textboxes, but no need to add all of them
6- Command Button "cmd_Add"
For now, If I will book for one user only, I have the following code
So, the above code is works great for one user booking
But, let's say 8 users will use 8 PCs for the same type and the same time....
I know the hard way that will be so difficult and huge code, which is:
If cmb_Num = "1" Then
'Enter the above code
If cmb_Num = "2" Then
'Enter the above code
'And again the same code (but instead of [ws.Cells(nr, "B") = Me.txt_Name1] use this [ws.Cells(nr, "B") = Me.txt_Name2]
If cmb_Num = "3" Then
'Enter the above code
'And again the same code (but instead of [ws.Cells(nr, "B") = Me.txt_Name1] use this [ws.Cells(nr, "B") = Me.txt_Name2]
'And again the same code (but instead of [ws.Cells(nr, "B") = Me.txt_Name1] use this [ws.Cells(nr, "B") = Me.txt_Name3]
.... Until 8
Is there any easy way to manage this:
Thanks in advanced
I have a userform "PC" to manage the PCs usage and timing
I have 8 PCs in each room, sometimes each one (or some of them) used for different type/time... and sometimes all of them for the same type/time...
In the userform "PC" I have the following controls
1- Combo Box "cmb_Num" (List from 1 to 8, to determine the number of users)
2- Text Boxes "txt_Name1 / txt_Name2 / txt_Name3.... until 8" (to fill the user's names)
3- Combo Box "cmb_Type" (list of usage types: research, Data Entry, Printing...)
4- Text Box "txt_Time" (to determine how long the user will use the PC: 30 Min, 1 Hour...)
5- There are many other textboxes, but no need to add all of them
6- Command Button "cmd_Add"
For now, If I will book for one user only, I have the following code
Code:
Private Sub cmd_Add_Click()
Dim ws As Worksheet
Set ws = Sheet15
If cmb_Num = "1" Then
nr = ws.Cells(Rows.Count, "A").End(xlUp).Row + 1
ws.Cells(nr, "A") = CDbl(ws.Cells(Rows.Count, 1).End(xlUp).value + 1)
ws.Cells(nr, "B") = Me.txt_Name1
ws.Cells(nr, "C") = Me.cmb_Type
ws.Cells(nr, "C") = Me.txt_Time
'And the rest of values
End If
End Sub
So, the above code is works great for one user booking
But, let's say 8 users will use 8 PCs for the same type and the same time....
I know the hard way that will be so difficult and huge code, which is:
If cmb_Num = "1" Then
'Enter the above code
If cmb_Num = "2" Then
'Enter the above code
'And again the same code (but instead of [ws.Cells(nr, "B") = Me.txt_Name1] use this [ws.Cells(nr, "B") = Me.txt_Name2]
If cmb_Num = "3" Then
'Enter the above code
'And again the same code (but instead of [ws.Cells(nr, "B") = Me.txt_Name1] use this [ws.Cells(nr, "B") = Me.txt_Name2]
'And again the same code (but instead of [ws.Cells(nr, "B") = Me.txt_Name1] use this [ws.Cells(nr, "B") = Me.txt_Name3]
.... Until 8
Is there any easy way to manage this:
- If there is one user, just fill the first empty row by the given data
- If there are 2 users, fill the first empty row by the given data, and the next row with same data unless the name (use txt_Name2)
- Same for 3 users, 4, 5...8
Thanks in advanced