exporting a worksheet for backup

  • Thread starter Thread starter sp00nix
  • Start date Start date
S

sp00nix

I would like to export the last worksheet in my workbook into a backu
dir. How can I do this without doing "Copy Worksheet" where it opens u
in the new work book? I would just like it to export while keeping onl
the current workbook open.
Thanks in advance,
Mik
 
this dose not do exactly what your asking, it saves the
whole file to a bu directory, adjust it to fit your needs

Sub CreateBackUp()
'need to creat the folder Bu if not their
Dim Num As Integer
Dim OrgPathSt As String
Const BUPath As String = "C:\BU\"
Dim BUPathName As String
Dim Wb As Workbook

On Error GoTo CreateDir
Application.ScreenUpdating = False

Set Wb = ActiveWorkbook

OrgPathSt = Wb.Path & "\" & Wb.Name
If Left(OrgPathSt, 1) = "\" Then
MsgBox "You must name & save your file first,
Via 'File' then 'Save As'"
Exit Sub
End If
BUPathName = "C:\BU\" & Left(Wb.Name, Len(Wb.Name) -
4) & _
" (" & Year(Date) & "-" & Month(Date) & "-" & Day
(Date) & " " & Hour(Time) & "." & Minute(Time) & "." &
Second(Time) & ")" & ".xls"

Num = MsgBox("Do you wish to save the Current file
as:" & vbNewLine & "[ " & OrgPathSt & " ]" _
& vbNewLine & vbNewLine & "And Create the Backup
File:" & vbNewLine & "[ " & BUPathName & " ]",
vbOKCancel, "Back Up")
If Num = vbCancel Then Exit Sub

Wb.Save
SaveAsBu:
Wb.SaveAs FileName:=BUPathName
Wb.Close

Workbooks.Open FileName:=OrgPathSt

Application.ScreenUpdating = True
Exit Sub
CreateDir:
MkDir "BU"
GoTo SaveAsBu
End Sub
 
I doubt you can, but you can make the action not visible

Application.ScreenUpdating = False
worksheets(worksheets.count).Copy
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs "C:\myfolder\myfile.xls"
Application.DisplayAlerts = True
ActiveWorkbook.Close SaveChanges:=False
Application.ScreenUpdating = True
 
Thanks, I have made similar code but my original question kind of
stumped me. Anyone have any other ideas?
Mike
 
One reason I didn't want to copy the ws to a new wb is because it won'
copy the complete cell if it has more than 255 chars. Is there any wa
around this issue? Thank
 
Dim rng as Range
Application.ScreenUpdating = False
set rng = worksheets(worksheet.count).Cells
worksheets(worksheets.count).Copy
rng.copy Destination:=Activesheet.Cells
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs "C:\myfolder\myfile.xls"
Application.DisplayAlerts = True
ActiveWorkbook.Close SaveChanges:=False
Application.ScreenUpdating = True

--
Regards,
Tom Ogilvy


Tom Ogilvy said:
I doubt you can, but you can make the action not visible

Application.ScreenUpdating = False
worksheets(worksheets.count).Copy
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs "C:\myfolder\myfile.xls"
Application.DisplayAlerts = True
ActiveWorkbook.Close SaveChanges:=False
Application.ScreenUpdating = True
 
One way might be to delete all but the last worksheet and saveas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top