Passing variables between code?

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,922
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have an event trigger in my workbook (that monitors report delivery deadlines) that when the workbook is opened, it cycles through some defined sheets and alerts the user if a report is due that day.

I'm in the seperate process of creating a module that will email a manager if a report is due and/or overdue (the workbook is opened daily), however, I'm stuck on how to call it correctly against a particular due/overdue report.

Code sort of looks like this:
Rich (BB code):
Sub Check_Reports()
' This is part of the workbook code as an event trigger
Dim i as long, j as long
For i = 1 to 4
  For j = 8 to sheets(i).Range("G" & Rows.Count).End(xlUp).Row
    If sheets(i).Range("G" & j) is past the due date then ' can't be bothered to type this bit of code out, there's some other checks too.
      msgbox Sheets(i).Range("G" & j) & " report is due"
      Call Send_Email
    End If
  Next j
Next i
End Sub
But..
Rich (BB code):
Call Send_Email ()
' Stolen from Ron de Bruin (thank you!)
End Sub
Is a generic bit of code to send a single pre-defined email.

What I'd like is for the event trigger code Check_Reports; when it evaluates the IF condition for TRUE, to send that report into the Send_Email procedure for every report it tests. I'm pretty sure this means passing the value of Sheets(i).Range("G" & j) into Send_Email but I'm stuck on how to do this.

Any suggestions or help please?

Thank you,
Jack
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Code:
Sub SendMail(repName)

'Stuff goes here

End Sub

and when calling it


Code:
Call Send_Email(sheets(i).Range("G" & j).value)
</pre>
 
Upvote 0
Thanks Scott, you're a legend. No wait, I should probably test that first before praising you.. but it should work!

Cheers,
Jack
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top