VBA - Autofill a VLookup Formula (under a filter)

Retrorock

New Member
Joined
Dec 18, 2017
Messages
3
Hi all, I'm currently trying to make a macro which autofills a Vlookup from another workbook.
I managed to get most of the macro working, except that it would't autofill to the rest of the empty spaces in row BA no matter what I tried. It was to only be the empty cells under the filters setup, so that probably raised the difficulty a bit too. Can someone help?
Thank you in advance

Workbooks.Open ("C:\Users\Mine\Documents\mc\Macro\2.xlsx") myFileName = ActiveWorkbook.Name
mySheetName = ActiveSheet.Name
myRangeName = Range("F:H").Address

Workbooks("2018 MC ODD List.xlsm").Activate
ActiveSheet.Range("$A$1:$BF$1051").AutoFilter Field:=49, Criteria1:="Yes"
ActiveSheet.Range("$A$1:$BF$1051").AutoFilter Field:=53, Criteria1:="="

Range("BA1").Select
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.EntireRow.Hidden = False
ActiveCell.Offset(1, 0).Select
Loop

ActiveCell.Formula = "=VLOOKUP(H6,[" & myFileName & "]" & mySheetName & "!" & myRangeName & ",3,0)"
ActiveCell.Copy
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.EntireRow.Hidden = False
ActiveCell.Offset(1, 0).Select
ActiveCell.PasteSpecial
Loop

Windows("2.xlsx").Activate
ActiveWindow.Close
End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top