View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Peter[_28_] Peter[_28_] is offline
external usenet poster
 
Posts: 60
Default Macro problem - help please

On Fri, 06 May 2005 08:04:49 -0500, Dave Peterson
wrote:

First, is this a button on a userform (designed in the VBE) or is this a
worksheet designed to look like a form? From your earlier post, it sounded like
it was a worksheet--but then I see "Unload me", so I'm confused.

I'm gonna guess that it's on the worksheet named Rotas and does the work against
the worksheet named Dates:

Option Explicit
Private Sub CommandButton_Snd_Click()

Dim wb As Workbook
Dim Fpath As String
Fpath = "Y:\Callout rotas\"
Application.ScreenUpdating = False
With Sheets("dates")
.Rows(1).Delete
.Copy
End With

Set wb = ActiveWorkbook
With wb
.SaveAs Fpath _
& Format(.Worksheets(1).Range("c2"), "dd-mmm-yy") & ".xls"
'.SendMail
.Close False
End With
Application.ScreenUpdating = True

End Sub


Hi ADve,

Thanks for your help.

This is a userform and the button is contained on (in?) it. I've just
tried the above and again, it deletes the date from cell A1, but does
not delete Row 1. Also the deleted date now appears in cell C3. A copy
of the exact script (with the email address the only thing that is
altered)

Private Sub CommandButtonSnd_Click()
Dim wb As Workbook
Dim Fpath As String
Fpath = "Y:\Callout rotas\"
Application.ScreenUpdating = False
With Sheets("Dates")
.Rows(1).Delete
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs Fpath & Format(Range("c2"), "dd-mmm-yy") & ".xls"
.SendMail ",Format(Range("c2"), "dd-mmm-yy")


.Close False
End With
Application.ScreenUpdating = True
Unload Me
End With

End Sub


--
Cheers

Peter