-
Jan 15th, 2017, 05:50 PM
#1
Thread Starter
New Member
[RESOLVED] VB: Making folder and saving workbook into that folder?
-
Jan 16th, 2017, 03:52 AM
#2
Re: VB: Making folder and saving workbook into that folder?
try like
Code:
ActiveWorkbook.SaveAs sfolder & Filename, xlOpenXMLWorkbook
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 16th, 2017, 11:51 AM
#3
Thread Starter
New Member
Re: VB: Making folder and saving workbook into that folder?
Originally Posted by westconn1
try like
Code:
ActiveWorkbook.SaveAs sfolder & Filename, xlOpenXMLWorkbook
Thanks, I needed to add another line so it would save in the folder created
sFolder2 = "C:\Users\User\Documents\Shipments\2017\" & Sheets("Input").Range("T4").Value & "\" & Sheets("Input").Range("T5").Value
and
ActiveWorkbook.SaveAs FileName:=sFolder2 & Ref
-
Jan 16th, 2017, 12:25 PM
#4
Re: VB: Making folder and saving workbook into that folder?
Thread moved to Office Development, since the question regards VBA.
My usual boring signature: Nothing
-
Jan 16th, 2017, 03:12 PM
#5
Re: VB: Making folder and saving workbook into that folder?
sfolder was already the name of the new folder, but i should have put a \ between
Code:
ActiveWorkbook.SaveAs sfolder & "\" & Filename, xlOpenXMLWorkbook
if you have a satisfactory answer, pls mark thread resolved
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 17th, 2017, 05:45 AM
#6
Thread Starter
New Member
Re: [RESOLVED] VB: Making folder and saving workbook into that folder?
Hi all,, following on from the aboce
I have a macro to create a folder, name it from a certain cell and save the workbook to it. How can I get the folder to be named and read from another cell to include another name in the folder title IF that other cell has a name in it?
At the moment it does....
Read Cell (e.g.) Cell A1 (Shipment1)
Make folder with name from A1
Save Workbook into Toby folder
Done
What I would like... IF Cell A2 contains information....
Read Cell (e.g.) Cell A1 (Shipment1) & A2 (Tom)
Make folder with name from A1 & A2 - Shipment1 Tom
Save Workbook into Toby folder
How do I make the IF info?
Thanks
-
Jan 17th, 2017, 09:32 AM
#7
New Member
Re: [RESOLVED] VB: Making folder and saving workbook into that folder?
From how it sounds, you can actually always use A1 & A2 without If clause - if A2 is empty, A1 & A2 will default to A1.
If you still want the IF clause, it would be quite simple.
Code:
If Range("A2").Value = "" Then
sFolderName = Range("A1").Value
Else
sFolderName = Range("A1").Value & Range("A2").Value
End If
Unless I'm missing something?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|