Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using SaveCopyAs for Specified Data Range

Status
Not open for further replies.

tcgoth

IS-IT--Management
Aug 17, 2005
54
US
I have a spreadsheet that has a data input section at the top and a "Results" table at the bottom that uses the input data to calculate various estimates.

I want to create Command Button that will allow the user to Save ONLY the "Results" data range to a new file, with the file name derived from a input field.

I am using this code (which works), but this saves the entire workbook instead of just the selected range. I have thought of separating the Input and Results on separate tabs but it doesn't appear that you can save individual tabs either? Any ideas? Thanks much!

Code:
Private Sub CommandButton1_Click()
ActiveWorksheet.SaveCopyAs "C:\Documents and Settings\Terry\" & Sheet1.Cells(16, 2) & ".XLS"
End Sub
 
Switch the recorder on (Tools, Macro, Record.....)
Right click on one of the sheet tabs.
Choose either "move" or "copy" to a new workbook. Save that workbook. Close your file. Stop the macro recorder. Adapt the code.

If you need help post what you have to the VBA forum....

If any of your Results cells have more than 255 characters then use Move rather than copy. If you use move then be careful not to save the original workbook afterwards!

Hope that helps,


Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top