Okay guys. I got a simple question, and a Complex question.
Simple. I need to run this Macro on every sheet in a workbook. I have it so it works on the current active sheet.
So I assume a simple Loop with this Macro would allow me to do it, how would I structure so that it goes to the next tab regardless of what it is called.
Here is the current code
Okay! Now for the the more complex problem. Below is a sample (No Real Data)
If I have multiple rows of customers, they are all sorted by smallest to largest on MDM - Available.
What i need is to have the macro above run, but select the header +all rows that have negative MDM - Available. So if there were 3 more in addition to the one below with -10, -3 , 7. It would only select to send the first one + the ones with -10 and -3 with the header.
This is variable number of records per tab. So tab 2 could have 10 records with negative MDM - Available, and tab 3 could have 3.
Also If there are no records with negative numbers, I would want it to SKIP.
Again would need this to loop to each tab.
<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
Simple. I need to run this Macro on every sheet in a workbook. I have it so it works on the current active sheet.
So I assume a simple Loop with this Macro would allow me to do it, how would I structure so that it goes to the next tab regardless of what it is called.
Here is the current code
Code:
Sub Send_Selection_Or_ActiveSheet_with_MailEnvelope()
'Working in Excel 2002-2013
Dim Sendrng As Range
On Error GoTo StopMacro
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Note: if the selection is one cell it will send the whole worksheet
Set Sendrng = Selection
'Create the mail and send it
With Sendrng
ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope
' Set the optional introduction field thats adds
' some header text to the email body.
.Introduction = "Good Afternoon, " & vbNewLine & vbNewLine & "Below you will find your accounts.
With .Item
.To = ActiveSheet.Name
.CC = ""
.BCC = ""
.Subject = "Please find below a list of all of your accounts."
.Send
End With
End With
End With
StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False
End Sub
Okay! Now for the the more complex problem. Below is a sample (No Real Data)
If I have multiple rows of customers, they are all sorted by smallest to largest on MDM - Available.
What i need is to have the macro above run, but select the header +all rows that have negative MDM - Available. So if there were 3 more in addition to the one below with -10, -3 , 7. It would only select to send the first one + the ones with -10 and -3 with the header.
This is variable number of records per tab. So tab 2 could have 10 records with negative MDM - Available, and tab 3 could have 3.
Also If there are no records with negative numbers, I would want it to SKIP.
Again would need this to loop to each tab.
SalesForce ID | Customer | Compliance Notes | Open Opportunities | Open Opp Device Level | Account Executive - Account | MDM - Active | MDM - Purchased | MDM- Available | AW Email Client | AW CL | AW BR | AW WS | SF Account Status | Hosting Model |
123456789dsa | ABC Corp | TRUE-UP - ABC Corp | 15 | John Rhodes | 86 | 70 | -16 | 0 | 9 | 0 | 0 | Active | AW SaaS |
<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>