Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 841717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:50:40+00:00 2026-05-15T05:50:40+00:00

Private Sub sendemail(esubj) Sheets(Actual).Select myfridate = Cells(1, 3).Value myfridate = DateAdd(d, -2, myfdate) myfridate

  • 0
Private Sub sendemail(esubj)

    Sheets("Actual").Select
    myfridate = Cells(1, 3).Value
    myfridate = DateAdd("d", -2, myfdate)
    myfridate = Format(myfridate, "mm-dd-yy")

    Sheets("Actual").Select
    mysatdate = Cells(1, 3).Value
    mysatdate = DateAdd("d", -1, myfdate)
    mysatdate = Format(mysatdate, "mm-dd-yy")


If Weekday(Now()) = vbMonday Then

    Set omail = CreateItem(olMailItem)

    ROW_BEGIN = 1
    ROW_END = 72

    Sheet1.Activate
    Range("I7").Select
    fileSat = "\\FINANCE\Daily Report\"
    fileSat = fileSat & Left(Range("I7"), 3) & Right(Year(Date), 2)
    fileSat = fileSat & "\Key Report - " & mysatdate & ".xls"

    Sheet1.Activate
    Range("I7").Select
    fileSun = "\\FINANCE\Daily Report\"
    fileSun = fileSun & Left(Range("I7"), 3) & Right(Year(Date), 2)
    fileSun = fileSun & "\Key Report - " & mysundate & ".xls"

    Sheet1.Activate
    Range("I7").Select
    fileFri = "\\FINANCE\Daily Report\"
    fileFri = fileFri & Left(Range("I7"), 3) & Right(Year(Date), 2)
    fileFri = fileFri & "\Key Report - " & myfridate & ".xls"


    With omail

    .Subject = "M Daily Report"
    .BodyFormat = olFormatHTML
    .HTMLBody = "<a href ='" & fileFri & "'>Key Report - " & myfridate & "</a><br><a href ='" & fileSat & "'>Key Indicator Daily Report - " & mysatdate & "</a><br><a href ='" & fileSun & "'>Key Indicator Daily Report - " & mysundate & "</a>"
    .To = "Me"
    .Display

    End With

    Set omail1 = CreateItem(olMailItem)

    With omail1

    .Subject = "R Daily Report"
    .BodyFormat = olFormatHTML
    .To = "You"
    .Attachments.Add fileFri
    .Attachments.Add fileSat
    .Attachments.Add fileSun
    .Display

    End With

    Set omail2 = CreateItem(olMailItem)

    With omail2

    .Subject = "Mc Daily Report"
    .BodyFormat = olFormatHTML
    .To = "them"
    .Attachments.Add fileFri
    .Attachments.Add fileSat
    .Attachments.Add fileSun
    .Display

End With

Else

    ROW_BEGIN = 1
    ROW_END = 72

    Sheet1.Activate
    Range("I7").Select
    fileSun = "\\FINANCE\Key Indicator\"
    fileSun = fileSun & Left(Range("I7"), 3) & Right(Year(Date), 2)
    fileSun = fileSun & "\Key Report - " & mysundate & ".xls"


    Set omail = CreateItem(olMailItem)

    With omail

    .Subject = "M Daily Report"
    .BodyFormat = olFormatHTML
    .HTMLBody = "<a href ='" & fileSun & "'>Key Report - " & mysundate & "</a>"
    .To = "Me"
    .Display

    End With

    Set omail1 = CreateItem(olMailItem)

    With omail1

    .Subject = "R Daily Report"
    .BodyFormat = olFormatHTML
    .To = "You"
    .Attachments.Add fileSun
    .Display

    End With

    Set omail2 = CreateItem(olMailItem)

    With omail2

    .Subject = "Mc Daily Report"
    .BodyFormat = olFormatHTML
    .To = "them"
    .Attachments.Add fileSun
    .Display

End With

End If

'ActiveWorkbook.Close
Set omail = Nothing

End Sub

I have code in vba, where if the weekday is monday, excel will generate 3 emails with 3 attachements/links. But if it is not Monday, excel will generate 3 emails with only 1 attachment/link. My issue is that In my excel spreadsheet there is a tab called Actual and it is populated with a date. If this date within my excel spreadsheet is changed on a monday, to any other day of the week, my vba code will still treat the program as if it is Monday. I need an IF statement that will allow the 3 emails with the 3 attachements/links to generate given the date typed in on the Actual tab within my spreadsheet. I hope this isnt confusing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:50:41+00:00Added an answer on May 15, 2026 at 5:50 am

    To specify a different action for Friday or Saturday, you would add a second statement using Elseif.

    If Weekday(Worksheets("Actual").Range("A1").Value) = vbMonday Then
        'Do this
    Elseif Weekday(Worksheets("Actual").Range("A1").Value) = vbFriday or _
    Weekday(Worksheets("Actual").Range("A1").Value) = vbSaturday Then
        'Do this instead
    Else
        'What happens for all other days
    End If
    

    The “Do this instead” if the day is Friday or Saturday could be as simple as “Exit Sub” which means nothing happens. Note that the “or” statement requires you to re-state all of the conditions. Pseudocode: “If today is Friday OR Saturday” will not work, you have to use “If today is Friday or if today is saturday”.

    If you found your needs to be even more specific you could set up a switch statement for each day of the week.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Private Sub CheckBox9_Click() If CheckBox9.Value = True Then CheckBox9.Caption = Done ActiveWorkbook.Sheets(Well Planning Checklist).Tab.ColorIndex
Private Sub spin01_Change() lab01.Caption = spin01.Value If I keep pressing a spinButton the label
Private Sub Workbook_Open() Sheets(01).Delete Sheets(02).Copy before:=Sheets(02) Sheets(02 (2)).Name = 01 Form1.Show End Sub Form1
Private Sub Text46_AfterUpdate() Dim strSource2 As String strSource2 = SELECT [Product Code],[Stock Level],[Description] FROM
I made this procedure to help me re-use a select query: Private Sub selectQry(ByVal
Private Sub Command1_Click() Dim x As Integer For x = 1 To 100 List1.AddItem
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress Dim allowedChars
Private Sub Command1_Click() Dim dom As New DOMDocument Dim http As New XMLHTTP Dim
Private Sub cmdLogin_Click() On Error GoTo ErrorHandler Dim RowNo As Long Dim Id As
My Code: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.