+ Reply to Thread
Results 1 to 5 of 5

Excel to outlook appointment date based on row selection question

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    960

    Excel to outlook appointment date based on row selection question

    Hello,

    I was curious if the following code could be amended somehow so that the date range would be based on the row selected and then pull the date from column "D" of that same row selection? Ideally the user would select the row/date they want by selecting the row in column H. So if they selected cell H30 the appointment reminder would then populate in Outlook for the date in Column D, row 30, etc. Currently this code pulls in the date in cell S1 only. Any assistance would be greatly appreciated!

    Sub CreateAppt()
    On Error GoTo erHandle
    Dim olApp As Object
    Dim olItem As Object
    Dim dt As Date
    Dim dk As String
    Dim Msg As String, Ans As Variant
    Sheets("Log").Unprotect Password:="test"
     Msg = "Do you want to set an appointment reminder?"
     Ans = MsgBox(Msg, vbYesNo)
     Select Case Ans
     Case vbYes
    dt = Range("S1").Value
    dk = Range("S2").Value
    Set olApp = CreateObject("Outlook.Application")
    Set olItem = olApp.CreateItem(1)
    
    
    
    With olItem
        .Subject = Range("S3") 'Change to cell that has value for subject
        .Location = "Log"
        .Body = Format("#" & dk) ' & Range("S1")
        '.Body = Format("#" & dk & "  is the docket number to research")
        .ReminderMinutesBeforeStart = 0.5 * 60 '1 hours times 60 minutes
        .Start = Format(dt + 8.5 / 24, "mm/dd/yyyy hh:mm")
        .End = Format(dt + 9 / 24, "mm/dd/yyyy hh:mm")
       
        .AllDayEvent = False
        .Save
        Sheets("Log").Protect Password:="test"
    End With
    
    
    Exit Sub
    erHandle:
    If Err.Number = 13 Then
        MsgBox "Active cell must containt a date", vbCritical
    Else
        MsgBox "Error #" & Err.Number & vbCrLf & Err.Description
    End If
    
    Case vbNo
     GoTo Quit:
     End Select
     Sheets("Log").Protect Password:="test"
    Quit:
    
    
    End Sub
    Last edited by lilsnoop; 11-01-2020 at 11:46 AM.

  2. #2
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Excel to outlook appointment date based on row selection question

    any chance you can share an example file? See yellow banner above. So you want to send a reminder for the active row?

  3. #3
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    960

    Re: Excel to outlook appointment date based on row selection question

    maniacb-I've attached a sample workbook below. Thanks for taking the time to help!
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Excel to outlook appointment date based on row selection question

    Give this a try

    Sub CreateAppt()
    On Error GoTo erHandle
    Dim olApp As Object
    Dim olItem As Object
    Dim dt As Date
    Dim dk As String
    Dim Msg As String, Ans As Variant
    
     Msg = "Do you want to set an appointment reminder?"
     Ans = MsgBox(Msg, vbYesNo)
     Select Case Ans
     Case vbYes
    dt = Cells(Selection.Row, "G").Value 'Range("S1").Value
    dk = Cells(Selection.Row, "F").Value & "-" & Cells(Selection.Row, "H").Value 'Range("S2").Value
    Set olApp = CreateObject("Outlook.Application")
    Set olItem = olApp.CreateItem(1)
    
    
    With olItem
        .Subject = Range("S3") 'Change to cell that has value for subject
        .Location = "Log"
        .Body = Format("#" & dk) ' & Range("S1")
        '.Body = Format("#" & dk & "  is the docket number to research")
        .ReminderMinutesBeforeStart = 0.5 * 60 '1 hours times 60 minutes
        .Start = Format(dt + 8.5 / 24, "mm/dd/yyyy hh:mm")
        .End = Format(dt + 9 / 24, "mm/dd/yyyy hh:mm")
       
        .AllDayEvent = False
        .Save
     
    End With
    
    
    Exit Sub
    erHandle:
    If Err.Number = 13 Then
        MsgBox "Active cell must containt a date", vbCritical
    Else
        MsgBox "Error #" & Err.Number & vbCrLf & Err.Description
    End If
    
    Case vbNo
     GoTo Quit:
     End Select
    
    Quit:
    
    
    End Sub

  5. #5
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    960

    Re: Excel to outlook appointment date based on row selection question

    maniacb-That worked perfectly! Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Help with VBA outlook appointment start/end time question
    By lilsnoop in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-22-2020, 01:01 PM
  2. Linking excel cells containing date and time to appointment in outlook
    By MyExHell in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-17-2016, 10:09 AM
  3. [SOLVED] Excel Macro - Add Appointment To Outlook
    By bunnos in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-08-2014, 12:04 PM
  4. Automatic Outlook Appointment from Excel Help 2
    By conwaythibodeaux in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-23-2014, 04:40 PM
  5. Create Outlook Appointment in Excel VBA
    By newbie28 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-23-2011, 10:27 AM
  6. Outlook appointment Date and time variable
    By DB4284 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2010, 11:41 AM
  7. Linking excel to Outlook appointment
    By Slartibartfast in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 04-07-2009, 12:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1