Make 2 independent Subs use shared Data Values

Status
Not open for further replies.
M

mrsadmin

Hi team,

Just a quick question. Can I make 2 independent subs share, or call data values from a singular source.

example:

I have 6 subs currently that run off very similar data (sending mail to the helpdesk).

They are sent in groups of 2: 1 to the Helpdesk and 1 to the source of the original email notifying them that we have received it and sent it onwards (these are normally by 3rd party outlets).

Can I have:

Sub DistA Fwd

Sub DistA Reply

Use data (email, subject, to & from etc) from Sub DistA Core

Or something similar?

For the most part DistA values are the same for Fwd & Reply so there is a lot of duplicate code.

Cheers.

Code:
Sub DistA Fwd() 
 
'this is the basics, there is a lot more in common 
 
'-----     -----     -----     Setting Variables     -----     -----     -----'Set variable email addresses 
 
sup = "support@ domain"              'support system 
 
admin = "admin@ domain"          'future correspondence 
 
'-----     -----     -----     Getting data from original item     -----     -----     --- 
received = objitem.CC                                        'address which received original email 
 
dist = "distA"                                                     'Distributor short code 
 
distemail = objitem.SenderEmailAddress                 'distributors originating email 
 
custmail = objitem.To                                        'customers address from originating email "to" 
 
origemaildate = objitem.ReceivedTime 
 
End Sub 
 
Sub DistA Reply 
 
'repeat data 
 
'enter alternative message 
 
End Sub
 
Yes, if you declare them outside of the sub, at the top of the page. if you declare them constants the variable can't be changed

public const sup = "support@ domain"

public const admin = "admin@ domain"

How to: Declare A Constant (Visual Basic)

If you are using a variable and want to share it between macros, dim it at the top of the page.
 
Yes, if you declare them outside of the sub, at the top of the page. if you declare them constants the variable can't be changed




public const sup = "support@ domain"


public const admin = "admin@ domain"




How to: Declare A Constant (Visual Basic)




If you are using a variable and want to share it between macros, dim it at the top of the page.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P How many subs can run in one outlook VBA script Using Outlook 5
U When opening shared Calendar "The set of folders cannot be opened" Using Outlook 0
M Outlook 2016 outlook vba to look into shared mailbox Outlook VBA and Custom Forms 0
V Unchecking my calendar and leaving shared one visible Outlook VBA and Custom Forms 1
S Email Macros to go to a SHARED Outlook mailbox Draft folder...NOT my personal Outlook Draft folder Using Outlook 2
C Outlook 365 Multiple different Signatures on Shared Mailbox Using Outlook 0
Fozzie Bear Shared Calendar For Scheduled Tasks Using Outlook.com accounts in Outlook 3
Z Outlook 365 Automatically assign categories to incoming mail in a shared folder Round Robin Outlook VBA and Custom Forms 1
J Outlook 365 Forward Email Subject to my inbox when new email arrive in shared inbox Using Outlook 0
J Hide/disable "Groups", "Shared Calendars" Using Outlook 2
T Never-ending Reminders in Shared Calendars Using Outlook 3
S Outlook 365 Shared mailbox contact group member numbers not matching Using Outlook 0
P Emails assigned with a certain category (within a shared inbox) to be copied to a specific folder. Outlook VBA and Custom Forms 2
S Copy Tasks/Reminders from Shared Mailbox to Personal Tasks/Reminders Outlook VBA and Custom Forms 0
peterbata Shared Tasks Outlook for Mac Using Outlook 5
Fozzie Bear Shared Public Folders Access and Use Exchange Server Administration 0
S Excel VBA and shared calendar issue Outlook VBA and Custom Forms 3
J O365 - Adding Shared Google Calendar ICS link issue in O365 Using Outlook 0
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
N Having Shared Calendar shift to Current day Using Outlook 0
R Assign Categories "Round Robin" style but in a shared mailbox but on specific emails only Outlook VBA and Custom Forms 8
Fozzie Bear Outlook 2016 Creating a shared local Contacts folder Using Outlook 2
P Auto assign shared mailbox Outlook VBA and Custom Forms 1
C Pull Outlook shared calendars items from Excel Outlook VBA and Custom Forms 4
C Create new Message with shared contacts & BCC'ing recipients Outlook VBA and Custom Forms 0
R VBA for copying sent email to current folder under a shared mailbox Outlook VBA and Custom Forms 17
M Outlook 365 Searching all shared calendars Outlook VBA and Custom Forms 4
S newly added shared mailboxes downloading 500GB data a day Exchange Server Administration 1
R auto send email when meeting closes from a shared calendar only Outlook VBA and Custom Forms 2
A New email notification on shared mailbox Outlook VBA and Custom Forms 0
N Shared mailbox in cached mode Using Outlook 0
B Vba to monitor time to respond to emails using a shared mailbox Outlook VBA and Custom Forms 5
D Shared Mailbox question Exchange Server Administration 1
S Import contacts to a shared mailbox Outlook VBA and Custom Forms 2
R Copy Outlook Public Folders to a File Server Shared Folder Using Outlook 0
D Delete Emails from Senders in Shared Mailbox Outlook VBA and Custom Forms 1
E Accessing shared outlook folder doesn't work since switch to new outlook/excel Outlook VBA and Custom Forms 11
J Updating existing entry on shared calendar wants to send update from delegate Using Outlook 0
C Changed By field not displaying individual user's name in O365 Shared Mailbox Using Outlook 9
G Unable to dismiss reminders from share point list calendar shared in Outlook Using Outlook 2
M how to speed up search of shared contacts Using Outlook 0
M Using conditional formatting on a shared calendar with categories Using Outlook 6
S Recovering permanently deleted folder from shared mailbox Using Outlook 1
S How to extract mail items from multiple folders and shared mailboxes? Outlook VBA and Custom Forms 0
D Outlook macros to create meeting on shared calendar Outlook VBA and Custom Forms 10
C Outlook Shared Calendar Using Outlook 1
N Does a Shared Folder Policy override a Digital Signature Setting for macros? Outlook VBA and Custom Forms 6
K Other Shared Calendar on Outlook cannot change items Using Outlook.com accounts in Outlook 7
I Application_NewMailEx for shared mailbox Outlook VBA and Custom Forms 1

Similar threads

Back
Top