TheDadliestDad
New Member
- Joined
- Feb 17, 2022
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
Hello!,
I've been trying to wrap my brain around this for about 2 days now and decided to finally make an account to get some help. I'm trying to utilize a textbox entry on a userform to reference a specific worksheet for a time clock system. This is what I have so far for when the user actually clocks in...
I have the employee ID #'s as the names of separate worksheets so each employee's time clock info is on their own respective worksheet for ease of use for the supervisor.
I need to find a way to reference the employee ID that the user types into the userform to the actual worksheet I want to "point" to. As you can see above, I tried ThisWorkbook.Worksheets("K1001").ActiveCell.Column, but that gives me an error code: 438. I've also tried the method I outlined in the If statement because I originally thought that it was because the .Value I'm giving to the Sheets() was not a string for som. I added the CStr() to try and solve this, but no dice. From what I understand it really does not like me using the textbox value object in the way I'm using it, but I can't figure out a workaround. I'm really hoping there is a way to do this as it would make my life ten times easier! I would be more than happy to go into more explanation if I didn't give enough. Thank you in advance for any help!
I've been trying to wrap my brain around this for about 2 days now and decided to finally make an account to get some help. I'm trying to utilize a textbox entry on a userform to reference a specific worksheet for a time clock system. This is what I have so far for when the user actually clocks in...
VBA Code:
Private Sub clockInOut_Button_Click()
'Sheet = employeeID.Value
'Set ws = ThisWorkbook.Sheets(employeeID.Value)
c = ThisWorkbook.Worksheets("K1001").ActiveCell.Column
'c = 2
If c = 3 Then
Sheets(CStr(employeeID.Value)).ActiveCell = Format(Now, "mm-dd-yyyy,h:mm:ss AM/PM")
Sheets(CStr(employeeID.Value)).ActiveCell.Offset(1, -1).Select
Else
Sheets(employeeID.Value).ActiveCell = Format(Now, "mm-dd-yyyy,h:mm:ss AM/PM")
Sheets(employeeID.Value).ActiveCell.Offset(0, 3) = PWC.Value
Sheets(CStr(employeeID.Value)).ActiveCell.Offset(0, 4) = Description.Value
Sheets(CStr(employeeID.Value)).ActiveCell.Offset(0, 5) = salesOrderNum.Value
Sheets(CStr(employeeID.Value)).ActiveCell.Offset(0, 1).Select
End If
Call resetForm
End Sub
I have the employee ID #'s as the names of separate worksheets so each employee's time clock info is on their own respective worksheet for ease of use for the supervisor.
I need to find a way to reference the employee ID that the user types into the userform to the actual worksheet I want to "point" to. As you can see above, I tried ThisWorkbook.Worksheets("K1001").ActiveCell.Column, but that gives me an error code: 438. I've also tried the method I outlined in the If statement because I originally thought that it was because the .Value I'm giving to the Sheets() was not a string for som. I added the CStr() to try and solve this, but no dice. From what I understand it really does not like me using the textbox value object in the way I'm using it, but I can't figure out a workaround. I'm really hoping there is a way to do this as it would make my life ten times easier! I would be more than happy to go into more explanation if I didn't give enough. Thank you in advance for any help!