Macro to save file based on cell value

nuffi

New Member
Joined
Jun 8, 2010
Messages
3
Arcangelo from Italy asks: How can I write an Excel VBA macro to save the current Excel file with a filename derived from cell A1? <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
This macro is amazingly straight-forward: <o:p></o:p>

Public Sub SaveAsA1()<o:p></o:p></PRE>
ThisFile = Range("A1").Value<o:p></o:p></PRE>
ActiveWorkbook.SaveAs Filename:=ThisFile<o:p></o:p></PRE>
End Sub<o:p></o:p></PRE>
I'm totally lost on this "amazingly straight-forward" macro!!!! Could someone help if I tell you the SAVE location? It's<TABLE style="WIDTH: 61pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=81 border=0 x:str><COLGROUP><COL style="WIDTH: 61pt; mso-width-source: userset; mso-width-alt: 2592" width=81><TBODY><TR style="HEIGHT: 30pt; mso-height-source: userset" height=40><TD style="BORDER-RIGHT: #d4d0c8; BORDER-TOP: #d4d0c8; BORDER-LEFT: #d4d0c8; WIDTH: 61pt; BORDER-BOTTOM: #d4d0c8; HEIGHT: 30pt; BACKGROUND-COLOR: transparent" width=81 height=40>T:\COMMISSIONING\IJT\TIMELOG project\Staff#1. I'm just not certain what value I'm replacing in the Macro above.

Any help appreciated..
</TD></TR></TBODY></TABLE>
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Try

Code:
Public Sub SaveAsA1()
ActiveWorkbook.SaveAs Filename:="T:\COMMISSIONING\IJT\TIMELOG project\Staff#1\" & Range("A1").Value
End Sub
 
Upvote 0
Hi. Thanks for the rapid response.
Unfortunately I still get the message "Excel cannot access the file". I wondered if it couldn't access the network and altered the script to a blank sheet I'd saved on my C drive desktop, but still got the same message. If I could just check I'm attempting to do it right?

  1. Cell A1 has a persons name in it.
  2. I've created a file for the person to click on an macro button to unsure it always saves to the correct existing file.
I knew it would be one of those days.......
 
Upvote 0
Success. Sorry to have wasted your time, I believe the problem was based on my using the hash key to identify the person. as soon as I used their name it saved perfectly.

Thank you very much.
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,974
Members
448,537
Latest member
Et_Cetera

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