I have a pretty large excel file that houses a list of employees, a few columns of paycheck data, then a fiscal week assigned to when that data was collected.
I am trying to search though this data and match an employee with a specific fiscal week in a macro. I have a solution that finds the name, but wont print out the fiscal week and it is very slow and I'm sure that there are much better ways of doing this simple task. Below is what I have, it's pretty simple and in the end I will need to capture the data in the rows but for now I am just printing to have proof of concept.
Sub loop_test()
Dim ClientTable As Range
Dim rng1 As Range, rng2 As Range, desired_emp As String, desired_fw As Integer
desired_emp = Application.InputBox("Select an Employee", Type:=8)
desired_fw = Application.InputBox("What FW would you like to do this for?", Type:=8)
Set FullName = Sheets("Query5").Range("A:A")
Set FiscalWeek = Sheets("Query5").Range("F:F")
For Each rng1 In FullName.Columns(1).Cells
If rng1.Value = desired_emp Then
matched_name = rng1.Cells.Value
For Each rng2 In FullName.Columns(1).Cells
If rng2.Value = desired_fw Then
matched_fw = rng2.Cells.Value
End If
Next
End If
Next
Range("i3").Value = matched_name
Range("j3").Value = matched_fw
End Sub