ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel 2003 (https://www.excelbanter.com/excel-discussion-misc-queries/255053-excel-2003-a.html)

Neil Holden

Excel 2003
 
Is it possible to clear a range of cells so that it defaults back to template
once the user clicks the button, below is code to attach the excel woorkbook
in an email and once emails i want it to clear certain cells.


Sub Mail_Button66_Click()
'Working in 97-2007
Dim wb As Workbook
Set wb = ActiveWorkbook

If Val(Application.Version) = 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will be no
VBA code in the file you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro
again.", vbInformation
Exit Sub
End If
End If

On Error Resume Next
wb.SendMail "", _
"This is the Subject line"
On Error GoTo 0



End Sub


Jacob Skaria

Excel 2003
 
Do you mean
'For Contiguous range
Range("A1:A10").Clear

'For non-contiguous range
Range("A1,B2,C3").Clear

--
Jacob


"Neil Holden" wrote:

Is it possible to clear a range of cells so that it defaults back to template
once the user clicks the button, below is code to attach the excel woorkbook
in an email and once emails i want it to clear certain cells.


Sub Mail_Button66_Click()
'Working in 97-2007
Dim wb As Workbook
Set wb = ActiveWorkbook

If Val(Application.Version) = 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will be no
VBA code in the file you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro
again.", vbInformation
Exit Sub
End If
End If

On Error Resume Next
wb.SendMail "", _
"This is the Subject line"
On Error GoTo 0



End Sub


Neil Holden

Excel 2003
 
Do i place that at the bottom of my code? i need it to automatically clear
once the file is attached?

"Jacob Skaria" wrote:

Do you mean
'For Contiguous range
Range("A1:A10").Clear

'For non-contiguous range
Range("A1,B2,C3").Clear

--
Jacob


"Neil Holden" wrote:

Is it possible to clear a range of cells so that it defaults back to template
once the user clicks the button, below is code to attach the excel woorkbook
in an email and once emails i want it to clear certain cells.


Sub Mail_Button66_Click()
'Working in 97-2007
Dim wb As Workbook
Set wb = ActiveWorkbook

If Val(Application.Version) = 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will be no
VBA code in the file you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro
again.", vbInformation
Exit Sub
End If
End If

On Error Resume Next
wb.SendMail "", _
"This is the Subject line"
On Error GoTo 0



End Sub


Jacob Skaria

Excel 2003
 
Yes
--
Jacob


"Neil Holden" wrote:

Do i place that at the bottom of my code? i need it to automatically clear
once the file is attached?

"Jacob Skaria" wrote:

Do you mean
'For Contiguous range
Range("A1:A10").Clear

'For non-contiguous range
Range("A1,B2,C3").Clear

--
Jacob


"Neil Holden" wrote:

Is it possible to clear a range of cells so that it defaults back to template
once the user clicks the button, below is code to attach the excel woorkbook
in an email and once emails i want it to clear certain cells.


Sub Mail_Button66_Click()
'Working in 97-2007
Dim wb As Workbook
Set wb = ActiveWorkbook

If Val(Application.Version) = 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will be no
VBA code in the file you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro
again.", vbInformation
Exit Sub
End If
End If

On Error Resume Next
wb.SendMail "", _
"This is the Subject line"
On Error GoTo 0



End Sub



All times are GMT +1. The time now is 02:13 AM.

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