VLOOKUP Question

rollingzep

Board Regular
Joined
Nov 18, 2013
Messages
214
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to do a Vlookup between two sheets on a same workbook.
WS1, StockRec_Liquidity_Rpt has two columns Q and S which has to lookup col A of the second WS2, BBGRisk and get the values from col D of WS2, BBGRisk to fill values on col AB on WS1, StockRec_Liquidity_Rpt.

This is my code. While it fills up values matching Q of StockRec_Liquidity_Rpt to col A of BBGRisk, it fails to do the same for Col S. It fills up the header of Col D as the value than actual data.


VBA Code:
    'ws.Range("AB2:AB" & ws.Cells(Rows.Count, "Q").End(xlUp).Row).FormulaR1C1 = "=VLOOKUP(""*""&RC[-11]&""*"",BBGRisk!C1:C4,4,0)"
        With Sheets("StockRec_Liquidity_Rpt").Cells(1).CurrentRegion.Resize(, 35)
        Data = .Value
        With Sheets("BBGRisk").Cells(1).CurrentRegion
            For i = 2 To UBound(Data)
                Chk = Application.Match(Data(i, 17), .Columns(1), 0)
                If IsError(Chk) Then
                    Chk = Application.Match("*" & Data(i, 19) & "*", .Columns(1), 0)
                End If
                If Not IsError(Chk) Then Data(i, 28) = .Cells(Chk, 4)
            Next i
        End With
        .Value = Data
    End With
    ws.Range("AD:AD").NumberFormat = "@"
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I didn't quite get your routine. But can it be, you are casting the range here instead of value?

VBA Code:
If Not IsError(Chk) Then Data(i, 28) = .Cells(Chk, 4).Value
 
Upvote 0
I run and check your code, and find all work well including the col S part.
VBA Code:
Chk = Application.Match("*" & Data(i, 19) & "*", .Columns(1), 0)
:unsure:
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,852
Members
449,096
Latest member
Erald

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