Get path with cell value excel vba

Solved
atoch Posted messages 3 Status Member -  
atoch Posted messages 3 Status Member -
Hello everyone,

I have a path problem in my Excel 2013 file.
I have a model_folder in Windows with an Excel file in a subfolder.

I copy a model_folder from my Excel sheet, with cell values.
To stay within my company structure, I need to add a comma and a dash in the folder name, which gives for example: "D:\" & Range("D3") & "," & " " & Range("P3") & " " & Range("F4") & "-" & Range("U4"). It should be noted that the cell values are variable depending on each folder.
Example result: city, site 112636-GC.
Up to this point, no problem.
Then I want to search for the Windows folder that has a similar name, for example: "D:\" & Range("D3") & "," & " " & Range("P3"), which contains files like jpg, excel, mail, etc.
I want to copy these files into my subfolder "sales" of the created folder.
With a msgbox to ask: "do you want to copy the files?" yes or no.

Thank you in advance for your help.
Best regards, atoch.

3 answers

cs_Le Pivert Posted messages 8437 Status Contributor 730
 
Hello,

see this to browse a directory:

https://excel.developpez.com/faq/?page=FichiersDir#BoucleFichiers

and this to copy files:

https://excel-malin.com/tutoriels/vba-tutoriels/manipulation-basique-des-fichiers-en-vba/

and the choice MsgBoxes:

https://www.excel-pratique.com/fr/vba/boites_de_dialogue.php

1
atoch Posted messages 3 Status Member
 
Hello,

thank you for the information and the link.
my issue is the folder path:
source folder path =("D:\" & Range("D3") & "," & " " & Range("P3"))
or
destination folder path:
("D:\" & Range("D3") & "," & " " & Range("P3") & " " & Range("F4") & "-" & Range("U4") & " \ Vente")

these 2 paths do not point to their respective folders.
there is an error somewhere, but I don't know where.

if you have any idea...

best regards
0
cs_Le Pivert Posted messages 8437 Status Contributor 730
 
In doing this, you will see where the error is, you will be able to correct it:

MsgBox "D:\" & Range("D3") & "," & " " & Range("P3") MsgBox "D:\" & Range("D3") & "," & " " & Range("P3") & " " & Range("F4") & "-" & Range("U4") & " \ Vente"


already this:

"," & " "


is written like this:

", "


@+ The Woodpecker
0
atoch Posted messages 3 Status Member
 
Hello Le Pivert,

I have solved my problem.
By replacing &"," with the value of my cell &range("O3")& everything is back to normal and my path is correct and the file copying is working.
The range("O3") in my spreadsheet is: ,

Thank you for taking the time to help me

best regards
0