Hi All,
I have never used the vlookup function using VBA and I am looking for a bit of assistance.
I have 2 worksheets within my workbook named:
LookupValues
DatatoLookup
In the first Sheet named LookupValues I have the following:
JobRef Description
A1234 Replacment Des 1
B2345 Replacment Des 2
In the second sheet named DatatoLookup I have the following:
JobRef Description
A1234 Description a
B2345 Description b
C1234 Description c
D4567 Description d
A1234 Desription a
What I want to do is each month the JobRefs in LookupValues can change or may be blank = the user will input the value in the cells. I want to capture the values in these cells and look them up on the DatatoLookup worksheet for the specified range (the range could vary each month so I would need to ensure I am searching down to the last row of data)
If a match is found for the JobRef, I'd like to replace the Description held in the DatatoLookup against that JobRef with the value held in the corresponding cell in the Description filed within the LookupValues
I attemped to make a start on the code but didn't get too far. Here's what I have so far:
I have never used the vlookup function using VBA and I am looking for a bit of assistance.
I have 2 worksheets within my workbook named:
LookupValues
DatatoLookup
In the first Sheet named LookupValues I have the following:
JobRef Description
A1234 Replacment Des 1
B2345 Replacment Des 2
In the second sheet named DatatoLookup I have the following:
JobRef Description
A1234 Description a
B2345 Description b
C1234 Description c
D4567 Description d
A1234 Desription a
What I want to do is each month the JobRefs in LookupValues can change or may be blank = the user will input the value in the cells. I want to capture the values in these cells and look them up on the DatatoLookup worksheet for the specified range (the range could vary each month so I would need to ensure I am searching down to the last row of data)
If a match is found for the JobRef, I'd like to replace the Description held in the DatatoLookup against that JobRef with the value held in the corresponding cell in the Description filed within the LookupValues
I attemped to make a start on the code but didn't get too far. Here's what I have so far:
VBA Code:
Sub UpdateValues()
Dim Bi_JobNo As String
Dim Quart_JobNo As String
Bi_JobNo = Range("A2").Value
Quart_JobNo = Range("A3").Value
Application.WorksheetFunction.VLookup(Bi_JobNo,DatatoLookup.Range(A2:B5),2, False)
Application.WorksheetFunction.VLookup(Quart_JobNo,DatatoLookup.Range(A2:B5),2, False)