Hi,
I'm trying to implement automation in my office attendance workbook and for that i've written this code in between 2 sample sheets, attached are the 2 sheets in which i'm trying to take value from RAW_Data Sample Sheet from unique HRMS Id column and match that with Shrinkage_Sample Sheet HRMS Id Column and trying to update attendance in RAW sheet same as mentioned in the Shrinkage file.
So what i'm trying to do here is after defining fetch variable as variant, i'm trying to fetch the file from system with Application.GetOpenFileName function and store the file path in that variable and later i did tried to set this "fetch" variable with table 2 but it is not working
can you please help me with this code.
Attached are the file for RAW_Data and Shrinkage
I'm trying to implement automation in my office attendance workbook and for that i've written this code in between 2 sample sheets, attached are the 2 sheets in which i'm trying to take value from RAW_Data Sample Sheet from unique HRMS Id column and match that with Shrinkage_Sample Sheet HRMS Id Column and trying to update attendance in RAW sheet same as mentioned in the Shrinkage file.
So what i'm trying to do here is after defining fetch variable as variant, i'm trying to fetch the file from system with Application.GetOpenFileName function and store the file path in that variable and later i did tried to set this "fetch" variable with table 2 but it is not working
can you please help me with this code.
Attached are the file for RAW_Data and Shrinkage
VBA Code:
Sub attendance_module()
Dim raw As Workbook
Set raw = ActiveWorkbook
Dim Imp_Row As Integer
Dim Imp_Col As Integer
Dim Table1 As Range
Dim Table2 As Range
Dim cl As Range
Dim filename As Variant
Set filename = Application.GetOpenFilename("Excel Files (*.xlsx),*.xlsx", 1, "Please select recent shrinkage", , True)
Set Table1 = raw.Sheets("sheet1").Range("B2", Range("B2").End(xlDown))
Set Table2 = fetch.Sheets("sheet1").Columns("A:G")
Imp_Row = 2
Imp_Col = 8
For Each cl In Table1
Cells(Imp_Row, Imp_Col) = Application.WorksheetFunction.VLookup(cl, Table2, 7, False)
Imp_Row = Imp_Row + 1
Table2.UsedRange.Copy Table1.Range("h:h")
Next cl
MsgBox "Done"
End Sub