Using vlookup in VBA

jemwig

New Member
Joined
Mar 16, 2013
Messages
36
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I have the following VBA Code to extract a letter from a string in workbookA Sheet1

Sub jemwig()
Dim ce As Range
For Each ce In Range("A1:A100")
ce.Offset(0, 1).Value = Mid(ce.Value, 10, 1)
Next ce
End Sub

I need to use the extracted letter from the code above to be applied in a vlookup in a range (B3:C17 in workbookB sheet 1 and then return the lookup result from column 2 to a column of cells in WorkbookA sheet1

Would gratefully accept soultions thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi thanks for the pointer. Unfortunately I am still not being successful

What I really need to do is to:
1) extract the 10th character from a string in column A, and then
2) use that character to lookup a result in column 2 of a table in another workbook / worksheet range, and then
3) enter the lookup function result in column B. Then repeat for every row in the original column A

I hope that makes it clearer? TIA
 
Upvote 0
It would be very helpful if you uploaded some sample data that we can work with. Please use XL2BB to upload your sample. Do not post a picture as we cannot manipulate data in a picture.
 
Upvote 0
Hi I actually figured it out. Not very elegantly for sure but it works

For Each ce In Range("O2:O5000")

ce.Offset(0, 1).Value = Mid(ce.Value, 10, 1)

ce.Offset(0, 2).Value = Application.WorksheetFunction.VLookup(ce.Offset(0, 1), Workbooks("Personal.xlsb").Worksheets("Sheet1").Range("B3:C17"), 2, False)

Next ce

Columns("P:P").Select
Selection.EntireColumn.Hidden = True
Range("Q1").Value = "Year"
Columns("Q:Q").EntireColumn.AutoFit
 
Upvote 0

Forum statistics

Threads
1,215,695
Messages
6,126,262
Members
449,307
Latest member
Andile

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