I have only been using VBA for a few months and I feel like I have enough of a grasp on it to do most things but I am having issues with making my current project work.
Up to this point I have filtered my data to show only the rows I need to update the data for and cleared what used to be there. The problem I am having is that I need to update the first cell in column Y after the filter has been applied.
Example of what I normally would do.
If row 13 is the first row after the filer has been applied:
- In cell Y13 I would type "=VLOOKUP(D13,Sheet1!$D:$E,2,FALSE)"
- Then I would fill down the column
Below is the code I have been trying:
Any guidance would be appreciated!
Up to this point I have filtered my data to show only the rows I need to update the data for and cleared what used to be there. The problem I am having is that I need to update the first cell in column Y after the filter has been applied.
Example of what I normally would do.
If row 13 is the first row after the filer has been applied:
- In cell Y13 I would type "=VLOOKUP(D13,Sheet1!$D:$E,2,FALSE)"
- Then I would fill down the column
Below is the code I have been trying:
Code:
Selection.AutoFilter
ActiveSheet.Range("$A$1:$AK$" & LastRow2).AutoFilter Field:=1, Criteria1:="tam"
Columns("Y:Y").Select
Selection.ClearContents
Range("Y1").Select
ActiveCell.FormulaR1C1 = "in_b"
With Worksheets("Sheet2").AutoFilter.Range
Range("D" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Select
End With
RowOff = ActiveCell.Row
Range("Y" & RowOff) = Application.WorksheetFunction.VLookup(Sheets("Sheet2").Range("D" & RowOff), Sheets("Sheet1").Range("$D:$E"), 2, False)
Any guidance would be appreciated!