Satamanster
New Member
- Joined
- Feb 23, 2019
- Messages
- 5
Hello everyone. I'm trying to create a tool to copy the times my employees set on their log and paste them on a separe sheet the company used to log everyone's times.
I managed to have the code 95% to how I want it to be. One thing is missing... Actually making it work...
So I've used the rest of the code to process the data inside the daily log, add the times for people who sign in multiple times, etc. I have one and one problem only.
When I open the sheet that I use to track the log for some reason the value I pass on with a variable is not being found in the specefied range. If I look manually (with a Ctrl + F) I can find it. And I can see the code is opening the appropriate sheet. But then it can't find nor the corresponding date or the employee's initials.
I'm not uploading the entire code, just the portion that is not working as intended. Maybe you can figure out something I'm missing.....
In all seriousness I've looked up many ways to solve it but I can't get my way around it. May I had that the code is working as I'm getting msgBoxes stating that the value could not be found.
I'd be really glad if someone was able to help out!
I managed to have the code 95% to how I want it to be. One thing is missing... Actually making it work...
So I've used the rest of the code to process the data inside the daily log, add the times for people who sign in multiple times, etc. I have one and one problem only.
When I open the sheet that I use to track the log for some reason the value I pass on with a variable is not being found in the specefied range. If I look manually (with a Ctrl + F) I can find it. And I can see the code is opening the appropriate sheet. But then it can't find nor the corresponding date or the employee's initials.
I'm not uploading the entire code, just the portion that is not working as intended. Maybe you can figure out something I'm missing.....
VBA Code:
Dim varA As String
Dim varB As String
Dim varC As String
Dim foundRngD As Range
Dim foundRngN As Range
WB1.Activate
With Sheets("Temp Sheet")
LastRow = .Range("C" & Rows.Count).End(xlUp).Row
For r = LastRow To 1 Step -1
varA = .Cells(r, 1) ' Emplyee Position
varB = .Cells(r, 2) ' Employee Name
varC = .Cells(r, 3) ' Time in Position in minutes
WB2.Activate
Worksheets(varA).Select
' Find the row corresponding the log's Date.
With Worksheets(varA).Range("A1:A551")
Set foundRngD = .Find(What:=ProtimeDate, LookIn:=xlValues)
End With
If foundRngD Is Nothing Then
MsgBox "Data " & LogDate & " not available in sheet " & varA & ".", vbCritical
Else
MsgBox foundRngD.Address
End If
' Search for the appropriate column with employee Initials.
With Worksheets(varA).Range("A1:F1")
Set foundRngN = .Find(What:=varB, LookIn:=xlValues)
End With
If foundRngN Is Nothing Then
MsgBox "Initials" & varB & " not found on sheet " & varA & ".", vbCritical
Else
MsgBox foundRngN.Address
End If
Next r
WB1.Activate
End With
In all seriousness I've looked up many ways to solve it but I can't get my way around it. May I had that the code is working as I'm getting msgBoxes stating that the value could not be found.
I'd be really glad if someone was able to help out!