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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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