Here's my problem :
I have a sub in my main file (let's call it mainFile)doing this :
-Opening a file (the user chooses which file to open)
-Retrieve the name of this file in a variable
-Copy value of a few cells in file1, paste them in mainFile
in order to do that, my code looks something like this :
Workbooks.Open file1
fileName = ThisWorkbook.Name
Set source = Workbooks(fileName).Sheets("Feuil1")
Set target = Workbooks(mainFile).Sheets("Feuil1")
source.Range("A5:A66").Copy target.Range("T5")
but the variable fileName, instead of returning, for instance, "file1.xls", returns "mainFile.xls".
I guess it's because the sub is located in mainFile. But what can I use instead of ThisWorkbook.name ?
Thanks