Dear Team,
I have a database file that has whole data @attached from that data I simply want an output for that I have discovered a match function that is presently functioning with the same activesheet to extract it but I want to utilise it from the saved database
Code
Function EmpMatch(x As String, y As String)
Const StartRow = 2
Dim EndRow As Long
Dim iRow As Long
Dim k As Integer
Dim m As LongLong
'rootpath = "\'Share\NewData\Alberts\Database"
'afile = Dir(rootpath & "*.csv")
If InStr(1, y, "|") > 0 Or InStr(1, y, "/") > 0 Then
k = InStr(1, y, "|") Or InStr(1, y, "/")
'y = Left(y, InStr(1, y, "|") Or InStr(1, y, "/") - 1)
m = Left(y, k - 1)
Else
m = y
End If
'Z = InStr(1, Mystring, "|")
'K = Left(x, NWword - 1)
'With Worksheets("Database")
With afile.Sheets("EmpDataBase")
'EndRow = .Range("A:G").Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
EndRow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
For iRow = StartRow To EndRow
If Trim(.Range("B" & iRow).Value) = Trim(x) And .Range("F" & iRow).Value = m Then
'If .Range("B" & iRow).Value = x And .Range("F" & iRow).Value = y Then
EmpMatch= .Range("A" & iRow).Value
Exit Function
End If
Next iRow
End With
EmpMatch= "Notfound"
End Function
Display More
Please assist.