I have the following VBA-code
Dim directory As String, fileName As String
directory = "C:\User\Work\scorix\test_excel\"
fileName = Dir(directory & "*.xl??")
now I would like to change the code so that I would be able to read the path from a given Excel-Workbook cell and then build the fileName.
If I try
directory = Worksheets("Summary").Range("B2").Value
fileName = Dir(directory & "*.xl??")
it dose not work. It means at the end of day directory is empty and therefore fileName is empty.
In the next step I tried
With ThisWorkbook
directory = Sheets("Summary").Range("B2").Value
End With
it works! (But, why?, probably I did not understand the definition of With) However, in the next step
fileName = Dir(directory & "*.xl??")
filename is still empty. I tried everything with ActiveSheet however, without success!

fileName = Dir(directory & "\*.xl??")