ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save button (https://www.excelbanter.com/excel-programming/366022-save-button.html)

[email protected][_2_]

Save button
 
I have a Packing list on Sheet1,inventory Sheet2 and Customer info
Sheet3.
Sheet1 linked and formulated to pull data from sheet2 and sheet3. I
added save botton to save each packing list to another
folder(C:\Paking_List06) I would like to know how to write a VBA code
to export Sheet 1 to packing list folder.

Thanks


jseven

Save button
 
Give this a try:

Sub ExportSheet()
' Macro 6/30/2006 by Jamie Hildebrand
'
''''''''''''''''''''''''''''''
'PLACE DESIRED DESTINATION HERE
FilePath$ = "C:\Parking_List06\"

'''''''''''''''''''''''''''''''
'THIS FORMATS THE FILE WITH THE
'CURRENT DATE FOLLOWED WITH THE
'TEXT "_Parking_Export.xls"
FileName$ = Format(Date, "MMDDYY") & "_Parking_Export.xls"

If Dir(FilePath$ & FileName$) < "" Then
response = MsgBox("That file already exists. Do you want to
overwrite it?", vbYesNo)
If response < vbYes Then
response = Trim(InputBox("Edit this name to prevent overwriting
old file.", "Change Name", FileName$))
If response = "" Then MsgBox "You didn't enter anything.": Exit
Sub
FileName$ = response
Else
Kill FilePath$ & FileName$

End If
End If
Sheets("Sheet1").Copy
ActiveWorkbook.SaveAs FileName:=FilePath$ & FileName$
ActiveWorkbook.Close
MsgBox "Export Finished", vbInformation, "Status"

End Sub

Regards,
Jamie


wrote:
I have a Packing list on Sheet1,inventory Sheet2 and Customer info
Sheet3.
Sheet1 linked and formulated to pull data from sheet2 and sheet3. I
added save botton to save each packing list to another
folder(C:\Paking_List06) I would like to know how to write a VBA code
to export Sheet 1 to packing list folder.

Thanks



[email protected][_2_]

Save button
 
Thank you I am working on it.

jseven wrote:
Give this a try:

Sub ExportSheet()
' Macro 6/30/2006 by Jamie Hildebrand
'
''''''''''''''''''''''''''''''
'PLACE DESIRED DESTINATION HERE
FilePath$ = "C:\Parking_List06\"

'''''''''''''''''''''''''''''''
'THIS FORMATS THE FILE WITH THE
'CURRENT DATE FOLLOWED WITH THE
'TEXT "_Parking_Export.xls"
FileName$ = Format(Date, "MMDDYY") & "_Parking_Export.xls"

If Dir(FilePath$ & FileName$) < "" Then
response = MsgBox("That file already exists. Do you want to
overwrite it?", vbYesNo)
If response < vbYes Then
response = Trim(InputBox("Edit this name to prevent overwriting
old file.", "Change Name", FileName$))
If response = "" Then MsgBox "You didn't enter anything.": Exit
Sub
FileName$ = response
Else
Kill FilePath$ & FileName$

End If
End If
Sheets("Sheet1").Copy
ActiveWorkbook.SaveAs FileName:=FilePath$ & FileName$
ActiveWorkbook.Close
MsgBox "Export Finished", vbInformation, "Status"

End Sub

Regards,
Jamie


wrote:
I have a Packing list on Sheet1,inventory Sheet2 and Customer info
Sheet3.
Sheet1 linked and formulated to pull data from sheet2 and sheet3. I
added save botton to save each packing list to another
folder(C:\Paking_List06) I would like to know how to write a VBA code
to export Sheet 1 to packing list folder.

Thanks




All times are GMT +1. The time now is 07:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com