SaveAs save in right folder

goffy

New Member
Joined
Sep 10, 2012
Messages
10
Hi

I got this code:

Private Sub GemSom_Click()


If Dir(ThisWorkbook.Path & "" & Range("b6").Value & " " & Date, vbDirectory) = "" Then
MkDir ThisWorkbook.Path & "" & Range("b6").Value & " " & Date
End If


'Dim Path As String
'Dim FileName As String
'FileName = Range("b6").Value & " " & Date
'ThisWorkbook.SaveAs ThisWorkbook.Path & "" & Range("b6").Value & " " & Date


End Sub

The MkDir makes a folder, but how do i get to save the file i the folder just created? Itried "ThisWorkbook.Path\Range("b6").Value & " " & Date" to try somthing but as expected it did not work.

Hope someone can help :)
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
The save to path including file name is the same as the folder you just created

This looks strange given how you have created the folder but I am sure you get the idea

Code:
[SIZE=2]ThisWorkbook.SaveAs ThisWorkbook.Path & "" & Range("b6").Value & " " & Date & "\" & FileName[/SIZE]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,402
Messages
6,119,301
Members
448,885
Latest member
LokiSonic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top