You are here:

Excel/Save to desktop macro

Advertisement


Question
I have a macro problem in excel.  I have a workbook with multiple worksheets.  Each worksheet has multiple vlookup functions (as well as some calculation formulas). This is an excel file that I maintain and a new updated copy is sent out to our sales force every quarter.  They use the file for various things (order sample product, filing complaints, ordering literature, etc.). I already have a "clear form" button placed at the bottom of each page that will clear the form and revert it back to the original blank form.  What I would like to do is place a "save" button at the bottom of each page that will allow each of our salesmen to simply click the button and have a copy (of that particular worksheet only) saved to their desktop.  I would also need the saved file to sever all ties to the original document (keep the data that they have typed, but remove all formulas).  And, if possible, it would be nice if a box popped up and let them know where it is being saved and under what name.  Could the name of the file have that days date automatically added also?  I've searched the internet, but can't find anything that fits exactly what I need.  Please HELP!  I am so confused and am at a loss.

Answer
Try this,written in XL'07

Change folder location if required.
Sub SaveSheetasValues()
   Dim nm As String, Wbk1 As Workbook, myFile As String, MyDir As String
   nm = ActiveSheet.Range("A1")    'names the sheet by whatever is in range A1
   ActiveSheet.Cells.Copy
   MyDir = "C:\Documents and Settings\valued customer\Desktop"
   Set Wbk1 = Workbooks.Add(Template:=xlWBATWorksheet)
   Wbk1.Worksheets(1).Name = nm
   Wbk1.Worksheets(1).Range("A1").PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone _
                                             , SkipBlanks:=False, Transpose:=False
   ChDir MyDir
   myFile = MyDir & Wbk1.Worksheets(1).Name & ".xlsx"
   Wbk1.SaveAs Filename:=myFile
   Wbk1.Close False
   MsgBox myFile & " has been saved to your desktop"

End Sub

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Dave Morrison

Expertise

I can answer most excel questions My Website is davesexcel.com

Experience

I have been working with spreadsheets since 1991. I am a self-trained excel developer since 2005.

Publications
My website davesexcel.com

Education/Credentials
Business admin. U of R.

Awards and Honors
Microsoft Excel MVP 2011-2012

©2016 About.com. All rights reserved.