How to do Vlookup using VBA to sheet which is filtered?

dmadhup

Board Regular
Joined
Feb 21, 2018
Messages
146
Office Version
  1. 365
Hi,

I am doing vlookup to filtered sheet using this code:

VBA Code:
Sub test()
Sheets("Sheet1").Select
Range("B2:B6").SpecialCells(xlVisible).FormulaR1C1 = "=VLOOKUP(rc1,Sheet2!c1:c3,2,FALSE)"
End Sub

This code works well when sheet1 is filtered. But In my case Sheet2 is filtered not sheet1.

I want to do vlookup from sheet1 (Not filtered) to the sheet2 (filtered). Is there any way I can modify my code to achieve this?

Any help is appreciated.
Thank you!
 
You right. That error is gone. But I am getting blank values which I need to check formula.
It means exceeds the Array size.

By the way in this line ROW($B$2:$B$10000)-ROW($B$14). From which sheet it gets the data?

For example:
OFFSET('[Master_Quote.xlsx]Quote_History1'!$B$2:$B$10000,ROW($B$2:$B$10000)-ROW($B$14),0,1)

Does line ROW($B$2:$B$10000)-ROW($B$14) get data from Master_Quote.xlsx?
You need to change $B$14 to $B$2 in "ROW($B$2:$B$10000)-ROW($B$14)".

It doesn't matter which sheet it refers to. This part generates an array of {0,1,2,3.....9999}.
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
You need to change $B$14 to $B$2 in "ROW($B$2:$B$10000)-ROW($B$14)".

It doesn't matter which sheet it refers to. This part generates an array of {0,1,2,3.....9999}.


I see.
Thank you so much for your help and solving my problem.
I know its been long discussion....Appreciated!
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,397
Members
449,081
Latest member
JAMES KECULAH

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