Share via

Excel VBA get file path.

Anonymous
2018-03-09T13:48:31+00:00

Hi Excel Gurus

The code below is from a macro that opens a workbook (path in cell Y2) moves worksheet to that worksheet. 

That works very well if you always run it from one computer.  I would like to change the macro so that the first part of the path with a path (up to the folded) picked with the file picker and add the file name in cell A2 of the sheet.

 Set wbkSrc = ActiveWorkbook

    For i = wbkSrc.Worksheets.Count To 11 Step -1

        Set wsh = wbkSrc.Worksheets(i)

        strFile = wsh.Range("y2").Value

        Set wbkTrg = Workbooks.Open(strFile)

Thanks

Es

[ Moved from: Office / Excel / Windows other / Office 365 Home ]

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2018-03-13T17:05:37+00:00

    Thank you that was very helpful.

    Was this answer helpful?

    0 comments No comments