Vlookup from other Sheet vba

vikas_newports

Board Regular
Joined
May 26, 2016
Messages
121
Office Version
  1. 365
Platform
  1. Windows
IN VBA , I want to use vlookup from the other sheet within the same workbook but I do not want to use worksheet name (DOVE) in formula
Currently, I am using the below formula and it is working fine

VBA Code:
 Range("C2").Formula = "=VLOOKUP(B2,DOVE!$C$14:$C$1048576,1,0)"
 
Hello again Vikas,
will you be satisfied with formula in format like picture 1. or some different string instead "xxxx"?

CaptureVlookup1.PNG



CaptureVlookup2.PNG


If yes, you can use "Name manager" and define name for range in the sheet "DATA" like picture 3 shows.

CaptureVlookup3.PNG



If you were try that without sucsess, take care about two things.
First when formula is inserted in the workbook1 data will not apear automaticaly if calculation options is not turned to "Automatic".
And second... you can get full file path in the formula or in the name manager if not both workbooks opened.
I hope this is little bit closer to the resloving to your problem.
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
If you want to insert formula with VBA jus use variable defined in the name manager in the VBA code.
VBA Code:
ActiveSheet.Range("A1").Formula = "=VLOOKUP(A2,xxxx,1,0)"
 
Upvote 0
I want to avoid from sheet name
You can't, no matter what you used in VBA the formula in the cell MUST have a sheet name.
The only other option would be to use Indirect, which has been described as Excel's most evil function.
 
Upvote 0
Fluff, yes I was thinking about INDIRECT function too can you share a example of usage ?
Meanwhile I tried below code and it is working fine
VBA Code:
Range("C2").Formula = "=VLOOKUP(B2,'" & Sheet2.Name & "'!$C$14:$C$1048576,1,FALSE)"
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,694
Members
448,979
Latest member
DET4492

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