Visual Basic for Applications (VBA) is a coding environment branch of Microsoft Programs that can do anything you want! I have been using VBA at my job for over a year now - it makes processes much easier because they are automatically done whenever you want. One of my favorite codes is that which sends an email using Microsoft Outlook. I needed to send emails to all retail stores (there were over 150) that were missing drawer counts (stored in an Excel sheet). Essentially, any 0 I saw I needed to notify the store. The first time I did it, it took about 7 hours. I decided to VBA code an email with the basic premise of what is below to email notification - the process now takes 2 seconds (all I need to do is click a button). This drastic improvement in efficiency is possible with nearly any process - I will be posting help for these processes. If you would like one custom-written, email me at info@excelandvba.com
Just in case you have never used it before - get to VBA by hitting ALT + F11
Basic Email Code:
Sub Email_Using_Outlook()
Dim myOutlook As Object
Dim myMailItem As Object
Set otlApp = CreateObject("Outlook.Application")
Set otlnewmail = otlApp.CreateItem(olMailItem)
With otlnewmail
.To = "info@excelandvba.com"
.CC = ""
.BCC = ""
.Subject = "This is the Subject"
.Body = "This is the body." & vbNewLine & "This is the 2nd line."
.Send
End With
End Sub
No comments:
Post a Comment