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...
M

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...
Excel VBA: Liebe Community! Ich habe Office 365. Ich habe eine Excel Vorlage mit VBA Codes. Diese Vorlage hat jetzt 3 Jahre perfekt funktioniert. Vor 1...
Office 365 keeps logging in with a messed up version of university account: Hi everybody, I'm using Office 365 as provided through my university. There must be some conflict between different versions of the same user...
Why doesn't rightclicking a start menu app and clicking on "open file location" open the actual file location but a weird shortcut location instead on: On Windows 10 rightclicking a start menu app and clicking on "open file location" doesn't open the files' "actual location" but just a folder in...
Excel VBA Code crashes PPT Presentation and leads to Error 462: Hallo, I have a Code, which starts in Excel and opens a PPT, updates the links, renames the PPT and closes it. The problem: Sometimes (not...

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