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

  • Using Teans with Office Professional Plus

    Using Teans with Office Professional Plus: Hello, we currently are using Office Professional Plus 2016 but would like to start using Teams as well. Is there a way to have both products...
  • Strange behavior when using Sharepoint WebDAV

    Strange behavior when using Sharepoint WebDAV: Hello, we are using Explorer View to access files on a SharePoint Online site. More specific a Teams SharePoint site. We are accessing the site...
  • Outlook 2016 is using the wrong output adress to send new mails

    Outlook 2016 is using the wrong output adress to send new mails: Hallo Einer Benutzer, hat ein komisches Problem in Outlook 2016, und zwar wenn er eine neue Mail in Outlook erstellt, will Outlook diese...
  • Microsoft Word 2016 crash when using different languages

    Microsoft Word 2016 crash when using different languages: When using Word 2016, after switching from German keyboard to Traditional Chinese and typing a word to translate to chinese characters, often the...
  • Ähnliche Themen
  • Using Teans with Office Professional Plus

    Using Teans with Office Professional Plus: Hello, we currently are using Office Professional Plus 2016 but would like to start using Teams as well. Is there a way to have both products...
  • Strange behavior when using Sharepoint WebDAV

    Strange behavior when using Sharepoint WebDAV: Hello, we are using Explorer View to access files on a SharePoint Online site. More specific a Teams SharePoint site. We are accessing the site...
  • Outlook 2016 is using the wrong output adress to send new mails

    Outlook 2016 is using the wrong output adress to send new mails: Hallo Einer Benutzer, hat ein komisches Problem in Outlook 2016, und zwar wenn er eine neue Mail in Outlook erstellt, will Outlook diese...
  • Microsoft Word 2016 crash when using different languages

    Microsoft Word 2016 crash when using different languages: When using Word 2016, after switching from German keyboard to Traditional Chinese and typing a word to translate to chinese characters, often the...
  • 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