Using Vlookup on other Workbook whichs path is stored in a Cell

Diskutiere Using Vlookup on other Workbook whichs path is stored in a Cell im Office Forum im Bereich Microsoft Community Fragen; Good Day Im Trying to do Vlookup on a closed Workbook whichs path is stored in a Cell. For that im writing a Function which opens the Workbook...

MSCom

Neuer Benutzer
Threadstarter
Dabei seit
20.09.2016
Beiträge
1
Good Day

Im Trying to do Vlookup on a closed Workbook whichs path is stored in a Cell.

For that im writing a Function which opens the Workbook by the path given, and then does the VLookup on a predefined range in the newly opened Workbook. Somehow my function doesnt work and i cant find out why.

Heres the function:

PosType is the Value to lookup in VLookup


Function getPos(PosType As String, FilePath As String) As String



Dim FileName As String


FileName = GetFilenameFromPath(FilePath)

Workbooks.Open FilePath





getPos = Application.VLookup(PosType, Workbooks(FileName).Worksheets("Sheet0").Range("A1:B50").Value, 2, False)



End Function


GetFilenameFromPath() returns only the Filename ("example.xlsx") like so:


Function GetFilenameFromPath(ByVal strPath As String) As String

' Returns the rightmost characters of a string upto but not including the rightmost '\'

' e.g. 'c:\winnt\win.ini' returns 'win.ini'



If Right$(strPath, 1) <> "\" And Len(strPath) > 0 Then

GetFilenameFromPath = GetFilenameFromPath(Left$(strPath, Len(strPath) - 1)) + Right$(strPath, 1)

End If

End Function


I have been trying to solve this for hours now but i just cant seem to find whats wrong with my code. Thanks for your help!
 
Thema:

Using Vlookup on other Workbook whichs path is stored in a Cell

Using Vlookup on other Workbook whichs path is stored in a Cell - Ähnliche Themen

File Format and Extension Mismatch during XML Import with XSLT Stylesheet: Dear All, I am importing the following XML into Microsoft Excel: <?xml version="1.0" encoding="utf-8"?> <?mso-application...
Error Power BI - Power Query Editor - Today function: Hi guys! Simple Problem: I want to make a function, which Shows if the a date from the column "End" is > = to Todays date or = null then "1" ...
Strange Excel behavior in some IF functions: Yesterday I was notified about the false calculation results in one of our interface files. After some research I came to the conclusion that the...
powershell: remove owners from list of members in o365 group: I'm the admin for a shool, that uses O365 for administration as well as classes. We mainly use Teams. OneNote and Email. I created teams for...
Access Database Not Working: Hello, I am trying to work with my Access database and keep getting the following message: The expression On Click you entered as the event...

Sucheingaben

royal poker

,

bovada pokNer bonus code

,

island view casino

,
island view Acasino
, replay poker, cashino classic, phoker machine, rampart casino, rampart casinKo, free texas holdem poker games, free texas holdem popker games, minnesota casinos, minnesota casinAos, bovada poker bonus code, casinlo tropez, casino tropez, royal pokcer, casino bingo, cCasino bingo, poker dining tables, all jackpots casino, poker palace, pioker palace, jackpot party cZasino slots, poker deck
Oben