General discussion

Locked

Macro that saves file w/name from a cell

By johnnyextreme ·
I'd like to make a macro that when run saves the current workbook to a new file in a certain location with a name that matches the current contents of a certain cell, A3 for instance. After data entry the clerk could run the macro and the file would be saved with the correct name. I've tried to record such a macro, but it saves the file with the same name even after I change that cell.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Macro that saves file w/name from a cell

by Dr. Dale In reply to Macro that saves file w/n ...

Create a new macro and insert the following lines of code:

Dim wbname As Variant

Range("A3").Select
wbname = ActiveCell.FormulaR1C1
ActiveWorkbook.SaveAs FileName:=wbname

This will save the current workbook to whatever is in cell A3. I would suggest adding some error checking to this procedure. There are some characters that you could type into this cell that would consitute an invalid filename, and thus cause the macro to fail.

Collapse -

Macro that saves file w/name from a cell

by Shanghai Sam In reply to Macro that saves file w/n ...

I just came back to the site to answer my own question, although my solution was slightly different:
dim wbname as string
wbname=range("A3).Value
ActiveWorkbook.SaveAs Filename:="G:\Billing\" & wbname & ".xls"
End Sub

Collapse -

Macro that saves file w/name from a cell

by johnnyextreme In reply to Macro that saves file w/n ...

This question was closed by the author

Back to Software Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums