• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need help with saving

Artisez

Member
Need a little help. I need to save a workbook based on 3 cell values for example A2, B2 and C2.

Cell A2 example "05-2024"
Cell B2 example "Planner"
Cell C2 is a timestamp =NOW()

1715185330931.png

Any help would be appreciated.

>>> use code - tags <<<
Code:
Sub SaveWorkbookAsXlsm()
    Dim wb As Workbook
    Dim folderPath As String
    Dim fileName As String
    Set wb = ActiveWorkbook
    folderPath = "C:\Art\"
    fileName = wb.Sheets("Sheet1").Range("A2").Value & "_" & _
               wb.Sheets("Sheet1").Range("B2").Value & "_" & _
               wb.Sheets("Sheet1").Range("C2").Value & ".xlsm"
    wb.SaveAs fileName:=folderPath & fileName, FileFormat:=52
End Sub
 

Artisez

Isn't this almost same as Your 15 March thread?
Three cells seems to be different.
What kind of help do You need with this?
 
Artisez, thanks to use the right vertical 3 dots icon when posting any VBA code.​
Within your thread vletm mentioned, see my post again …​
 
Sorry abt the code posting, I knew when I did it, it was not correct, but could not remember.

Yes similar to the one back in March, that code saves with the workbook name. I'm trying to get it to save with 3 cell values, for example
05-2024 Planner - 05-08 13:00. Not using the filename, the file name is causing some issues. (that code works great, but does not always update the save as we need)
 

Artisez

Last time Your real challenge was that You used value which has /.
... or it's okay, if You'll notice that each / means a folder.
Have You checked that there is none / in Your values in this time?
I can ask same question again ... what do Your those three cells have?
... I can see something, but that do not matter ... it matters, what is in cells.
... Those - what do You see - can get with Custom Formatting.
 
Cell A2 example "05-2024"
Cell B2 example "Planner"
Cell C2 is a timestamp =NOW()

1715185330931.png



I know the ":" may cause an issue, was just seeing if there was a way. I can change that format to "mm-dd 1120" Above is what is in the cells I wish to use.

I apologize for the trouble
 

Artisez

Okay ... You're writing about formatting something.
It's like with Your previous same kind of thread.
You should able to send a sample file.
 

Artisez

As I wrote in #2 reply Isn't this almost same as Your 15 March thread?
As asked few times from You:
What do You have ... cell A2 has 01/05/2024
and ... cell C2 has =NOW()
Screenshot 2024-05-09 at 09.52.57.png Screenshot 2024-05-09 at 09.53.04.png
If You try to solve - what is FileName's value ... eg like below
from Your code then
It'll be as below ... with MsgBox FileName
Screenshot 2024-05-09 at 09.57.58.png It have four times / and three times :
as I've tired to explain for You:
Each / means folder too and : are as well as challenges.
Do You get now idea that ... what do You see?
is different than ... what do You have?
Now, You could take care that FileName has only useful characters - okay?
Other my opinion is that FileName could be eg 2024-05_Planner_0951
Did You read my Your previous thread's #16 reply?
 
Back
Top