Vlookup, changing columns & VBA

The Student

New Member
Joined
Sep 27, 2018
Messages
24
Office Version
  1. 365
Platform
  1. Windows
9


Hello. Hope you can help me.

I got the following issue.
I like to do a VLOOKUP based on the column named price. But I have a problem. At work I receive different worksheets and the column "price" can be at a different range (like illustrated in the picture)
I´m making a lot of VLOOKUP and thought it could be nice if a VBA code could identify the Price column and make the VLOOKUP´s in a macro?


ml1h1w.jpg
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Please give a little more detail on what you want to do.
make the VLOOKUP´s in a macro
This statement doesn't really tell us much. Explain in detail what you want to do referring to specific cells, rows and columns.
 
Upvote 0
Assuming you only have one Price column on the sheet, try
Code:
Sub AddVlookup()
   Dim Fnd As Range
   
   Set Fnd = Cells.find("Price", , , xlWhole, , , False, , False)
   If Not Fnd Is Nothing Then
      Range("G8").Formula = "=vlookup(" & Fnd.Offset(1).Address(0, 10) & ",H:I,2,0)"
   End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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