Hi All,
PROBLEM:
When I AutoFilter my data to the favourite colour as 'Blue' (check before and after images), the first cell with data changes from A2 to A4 as A2 is filtered out. I run a VLOOKUP which works fine however, my problem is that the data I receive may change daily.
For example, in this example the first Row with the favourite colour Blue is A4, but tomorrow it might be A3 or A23 etc.
QUESTION:
Is it possible to dynamically automate this process so that my macro finds the correct cell to start the macro from itself instead of me having to specify what cell to begin the VLOOKUP from (in this instance I have selected Range A4 in the code).
Here is my code:
If this query isn't clear then let me know and I will try to explain in further detail.
second sheet
no filter
after filter
PROBLEM:
When I AutoFilter my data to the favourite colour as 'Blue' (check before and after images), the first cell with data changes from A2 to A4 as A2 is filtered out. I run a VLOOKUP which works fine however, my problem is that the data I receive may change daily.
For example, in this example the first Row with the favourite colour Blue is A4, but tomorrow it might be A3 or A23 etc.
QUESTION:
Is it possible to dynamically automate this process so that my macro finds the correct cell to start the macro from itself instead of me having to specify what cell to begin the VLOOKUP from (in this instance I have selected Range A4 in the code).
Here is my code:
VBA Code:
Dim Sheet1 as Worksheet
Set Sheet1 = Sheets("Sheet1")
Dim formul As String
Range("A:C").AutoFilter Field:=3, Criteria1:="Blue"
Range("A4").Select '//I would prefer to avoid specifying what cell to start from as the data changes daily
formul = "=VLOOKUP(RC[2],Sheet2!R1C1:R5C2,2,0)" '////Pulls back the comment from the second sheet in the image below
Range("A4:A" & Cells(Rows.count, 1).End(xlUp).Row) = [formul]
If this query isn't clear then let me know and I will try to explain in further detail.
second sheet
no filter
after filter