Excel 2016 Coding
Excel 2016 Coding
Sub Send_Mail()
'
'
'
With OutlookMail
.To = "Ted.Regan@mwra.com;Dan.Keough@mwra.com;"
.Cc =
"Brendan.bowler@mwra.com;Robert.Farrell@mwra.com;Robert.Spencer@mwra.com;Scott.Shaw@mw
ra.com;Dana.Marshall@mwra.com;Dean.Pevey@mwra.com;Mark.Cataldo@mwra.com;John.Bates@m
wra.com"
.Bcc = "
.Attachments.Add ActiveWorkbook.FullName
.Display
End With
End Sub
Sub SendWorksheetByEmail()
ThisWorkbook.SaveCopyAs FileFullPath
With OutMail
.Subject = "Worksheet"
.Attachments.Add FileFullPath
.Display ' Use .Send instead of .Display to send without showing the email
End With
' Clean up
End Sub
To apply conditional formatting in Excel based on the date in another cell, you can use a formula-based
rule. Here's an example of how you can do it:
1. Select the cell or range of cells that you want to apply conditional formatting to.
5. In the "New Formatting Rule" dialog box, select "Use a formula to determine which cells to format."
6. In the "Format values where this formula is true" field, enter the formula that references the cell
containing the date. For example, if you want to format cells in column B based on the date in column A,
you can use a formula like:
`=$A1=TODAY()`
Note: The dollar sign ($) before the column letter locks the column reference when the formatting is
applied to other cells.
If you want to format cells based on a specific date instead of the current date, you can replace
`TODAY()` with the desired date in the formula.
7. Click on the "Format" button to specify the formatting you want to apply to the cells that meet the
condition.
8. Choose the desired formatting options, such as font color, fill color, etc.
10. The formatting will be applied to the selected cells based on the date in the referenced cell.
Remember to adjust the cell references and formula based on your specific requirements.
Sub ReturnAndFormatDate()
dateValue = DateSerial(2023, 5, 12) ' Change the year, month, and day as needed
Range("A1").Value = dateValue
End Sub