pepsiguydrinkscoke
New Member
- Joined
- Jul 4, 2021
- Messages
- 4
- Office Version
- 2016
- Platform
- Windows
Hi! I'm new so please forgive me if this has already been posted elsewhere. I've been researching my problem for several weeks with no luck.
I work in healthcare and I have a spreadsheet for tracking employee data at multiple clinics. The employees are assigned to a specific clinic so I have 1 document with 16 sheets, 1 sheet for each clinic, with multiple employees listed per sheet. I've created a Userform for entering the employee data and found a beautiful bit of code that helped me be able to select a specific sheet to send the data entered in the Userform to. It works flawlessly.
My issue comes in when I have to update the employee's data. My Userform contains only the data that will be transferred to the specific sheet for the location they are assigned too and as of now, it only allows me to enter data, whether it's new or repeated information. I do not have a list box in my Userform to show the data being transferred to the sheet as this didn't seem necessary for my needs. I would like to know if there is a code that will allow me to search the workbook (or a specific sheet, if that's easier) for an employees name and have their information populate on the Userform to be able to update it and save the updated data on the sheet it came from. I also have not yet added a Search Command Button as I haven't found the right code. If by some miracle there is a code I can use, I'll add the search button then.
Unfortunately, I'm not allowed to download anything to my work computer so I'm not able to use the Mini-sheet feature so I've uploaded a screenshot of my Userform as well as a view of the Sheet the data transfers over to. I will also list the code I'm using for transferring my data below in case that helps. Please let me know if there is anything more I can provide.
I work in healthcare and I have a spreadsheet for tracking employee data at multiple clinics. The employees are assigned to a specific clinic so I have 1 document with 16 sheets, 1 sheet for each clinic, with multiple employees listed per sheet. I've created a Userform for entering the employee data and found a beautiful bit of code that helped me be able to select a specific sheet to send the data entered in the Userform to. It works flawlessly.
My issue comes in when I have to update the employee's data. My Userform contains only the data that will be transferred to the specific sheet for the location they are assigned too and as of now, it only allows me to enter data, whether it's new or repeated information. I do not have a list box in my Userform to show the data being transferred to the sheet as this didn't seem necessary for my needs. I would like to know if there is a code that will allow me to search the workbook (or a specific sheet, if that's easier) for an employees name and have their information populate on the Userform to be able to update it and save the updated data on the sheet it came from. I also have not yet added a Search Command Button as I haven't found the right code. If by some miracle there is a code I can use, I'll add the search button then.
Unfortunately, I'm not allowed to download anything to my work computer so I'm not able to use the Mini-sheet feature so I've uploaded a screenshot of my Userform as well as a view of the Sheet the data transfers over to. I will also list the code I'm using for transferring my data below in case that helps. Please let me know if there is anything more I can provide.
VBA Code:
Private Sub cmdSave_Click()
Dim cNum As Integer
Dim X As Integer
Dim nextrow As Range
Dim sht As String
sht = cmbClinicNumber.Value
If Me.cmbClinicNumber.Value = "" Then
MsgBox "Please select a Clinic Number."
Exit Sub
End If
cNum = 30
Set nextrow = Sheets(sht).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
For X = 1 To cNum
Me.Controls("Reg" & X).Value = ""
Next
MsgBox "Saved"
End Sub
Private Sub UserForm_Initialize()
Dim ws As Worksheet
For Each ws In Worksheets
Select Case ws.CodeName
Case "Sheet1", "Sheet4", "Sheet20" 'Hidden Sheets
Case Else
Me.cmbClinicNumber.AddItem ws.Name
End Select
Next ws
With Reg3
.AddItem "X"
End With
With Reg4
.AddItem "X"
End With
With Reg5
.AddItem "X"
End With
With Reg21
.AddItem "Immune"
.AddItem "Susceptible"
End With
End Sub