How to save Excel file with cell value?
When you use a workbook, have you ever thought to save the Excel file based on a cell content? For example, you have “Sale price” in cell A1, and you would like to save the workbook as the name Sale price. Of course, you can type the name into the Save As dialog, and then save it. But this will be an inefficient method in your amount of work. Today, I will talk about a quick trick to solve it.
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
The following VBA code may help you to save your workbook with a specified cell value, please do as follows:
1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Save Excel file with specific cell value
Private Sub filename_cellvalue() 'Update 20141112 Dim Path As String Dim filename As String Path = "C:\Users\dt\Desktop\my information\" filename = Range("A1") ActiveWorkbook.SaveAs filename:=Path & filename & ".xls", FileFormat:=xlNormal End Sub
3. And then press F5 key to execute the code, and your workbook has been named as the cell content of cell A1. See screenshot:
1. You can specify any cell value as the file name by just modifying the A1 to other cell reference in the above code.
2. Your active workbook will be saved into the folder of C:\Users\dt\Desktop\my information\ (the last slash must be remained when you paste your location to instead of it) location, you can change the path to your need.