Saving a Excel workbook with folder and filename from range of cell contents

garthkh

New Member
Joined
Oct 18, 2023
Messages
9
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Hi
I found a part of my answer in an old post but I would like extra help please. I'm not an expert at Excel or VBA.
I have a workbook that must be filled in by a number of different people each day, after each of 3 shifts. I have created a button with a VBA macro to save the workbook into a folder and filename supplied by a range of cell contents (A3, B3 C3, D3 and E3 where A3 is t be used as the folder name and the rest as a filename). I can't get the Cell A3 to use the existing folder on the desktop. The whole string gets saved onto the desktop as a filename AND I'm left with a workbook that now has the new filename.

I started the VBA module just to clear all entered cells at the end - hence the Sub still has this name.
I would really like to only save the sheet and not the whole workbook - and be left with just the original workbook template on my screen for the next person on shift to fill out.
I need to eventually have this workbook/worksheet saved into SharePoint in the 365 cloud where the Admins can access it once saved.

Sub ClearValuesOnly()

Dim Path As String
Dim filename As String
Dim folder As String
folder = Range("A3").Value
Path = "C:\Users\garth\Desktop\" & folder

ThisFile = Range("B3").Value & Range("C3").Value & Range("D3").Value & Format(Range("E3").Value, "dd-mm-yyyy")
ActiveWorkbook.SaveAs filename:=Path & ThisFile & ".xls"

Range("A3:D3").ClearContents
Range("B7:B28").ClearContents
Range("B40:B50").ClearContents
End Sub
 

Attachments

  • Client Care Form.png
    Client Care Form.png
    49.4 KB · Views: 25
Thanks so much for the help.
We now have a debug error when I submit the form - see image
 

Attachments

  • Debug1.png
    Debug1.png
    15.7 KB · Views: 7
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Could the fact that the sheet is protected, except for the cells to be filled in, be a problem in the ode working or not. My head is spinning trying to think of this coding. I can understand the code as I read it but I don't know the syntax. I really appreciate the help to get this sorted out. Would it help at all if I could send the spreadsheet to see the whole thing? I can put it into my Dropbox.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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