#1
|
|||
|
|||
Save Excel file with specific cell value by using VBA code
Help!! I am trying to finish a new tool to use in our shop and I have a couple of steps I can't figure out......
1) I would like to create a macro that will save a file using the contents of a specific cell (customers name) as the file name. I found this script that works, but I can't figure out how to execute the command! 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 and 2) I would like to record a macro that exports the .xlsm file into a .pdf, so I can send it to the customer in that format, not an excel file. |
#2
|
||||
|
||||
How you would execute the code depends on what you want to use it with. If it's intended to be run as a stand-alone macro, simply delete 'Private '. You will then be able to access it via Alt-F8, for example.
To save as a PDF, you'd probably want to use the ExportAsFixedFormat method, so you can specify the output range, etc. See Excel VBA help file for details. You could add that method to your existing sub.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Save as File for Excel 2010 | mbesspiata | Excel Programming | 2 | 02-03-2016 07:10 AM |
Save as File for Excel 2010 | mbesspiata | Excel | 1 | 11-18-2015 08:52 AM |
Code for mail merge to reference saved excel file | jtemp57 | Word VBA | 10 | 12-16-2013 11:02 PM |
VB code: populate combobox from columns in Excel file | billybeach | Outlook | 2 | 04-27-2013 04:38 AM |
Insert an item to excel specific cell | apjneeraj | Excel | 0 | 01-18-2011 03:39 AM |