copy the command button and macro for multiple rows
Joel~
It now requires that i be in the row and column a to fill the data in the
appointment (the data in the appointment actually comes from the row
underneath). before it would also create appointments for all rows at one
time.
--
problem
"joel" wrote:
the code below puts an X in column F when an appointment is made. Then
checks for X before making a new appointment
Private Sub CommandButton1_Click()
Dim Outlook As Object
Dim Appointment As Object
Dim Category As String
Dim Time As Variant
Const Item = 1
Set Outlook = CreateObject("Outlook.Application")
Time = "08:30AM"
With ActiveCell
For RowOffset = 0 To (Selection.Rows.Count - 1)
If .Range("F2").Offset(RowOffset, 0) < "X" Then
.Range("F2").Offset(RowOffset, 0) = "X"
Set Appointment = Outlook.CreateItem(1)
Appointment.Location = .Range("a2").Offset(RowOffset, 0) & _
", " & .Range("d2").Offset(RowOffset, 0) & ", " & _
.Range("e2").Offset(RowOffset, 0)
Appointment.Subject = .Range("i2").Offset(RowOffset, 0)
Appointment.Start = _
DateAdd("d", 350, .Range("b2").Offset(RowOffset, 0)) & _
" " & Time
Appointment.Body = _
.Range("a2").Offset(RowOffset, 0) & ", " & _
.Range("b2").Offset(RowOffset, 0) & ", " & _
.Range("c2").Offset(RowOffset, 0) & ", " & _
.Range("d2").Offset(RowOffset, 0) & ", " & _
.Range("e2").Offset(RowOffset, 0)
Appointment.ReminderPlaySound = True
Appointment.Display
End If
Next RowOffset
End With
'Outlook.quit
'Set Outlook = Nothing
End Sub
"bigproblem" wrote:
I was looking to have a command button included on each row and synced with
the data in that specific row BUT this is great.
Is there a way to prevent duplicate appointments from being made. For
example the data is entered on one day and appointments created then the day
after additional data is entered. If the command button is used it will
recreate appointments from the day before.
THANKS !!!
--
problem
"joel" wrote:
Not sure what you want. I think this will do. It assumes you have the cells
you want in the appointment selected. I can can the code to use an inputbox
to select the cells.
Private Sub CommandButton1_Click()
Dim Outlook As Object
Dim Appointment As Object
Dim Category As String
Dim Time As Variant
Const Item = 1
Set Outlook = CreateObject("Outlook.Application")
Time = "08:30AM"
With ActiveCell
For RowOffset = 0 To (Selection.Rows.Count - 1)
Set Appointment = Outlook.CreateItem(1)
Appointment.Location = .Range("a2").Offset(RowOffset, 0) & _
", " & .Range("d2").Offset(RowOffset, 0) & ", " & _
.Range("e2").Offset(RowOffset, 0)
Appointment.Subject = .Range("i2").Offset(RowOffset, 0)
Appointment.Start = _
DateAdd("d", 350, .Range("b2").Offset(RowOffset, 0)) & _
" " & Time
Appointment.Body = _
.Range("a2").Offset(RowOffset, 0) & ", " & _
.Range("b2").Offset(RowOffset, 0) & ", " & _
.Range("c2").Offset(RowOffset, 0) & ", " & _
.Range("d2").Offset(RowOffset, 0) & ", " & _
.Range("e2").Offset(RowOffset, 0)
Appointment.ReminderPlaySound = True
Appointment.Display
Next RowOffset
End With
'Outlook.quit
'Set Outlook = Nothing
End Sub
"bigproblem" wrote:
How can I copy the command button and macro for multiple rows ?
Private Sub CommandButton1_Click()
Dim Outlook As Object
Dim Appointment As Object
Dim Category As String
Dim Time As Variant
Const Item = 1
Set Outlook = CreateObject("Outlook.Application")
Set Appointment = Outlook.CreateItem(1)
Time = "08:30AM"
Appointment.Location = Range("a2") & ", " & Range("d2") & ", " & Range("e2")
Appointment.Subject = Range("i2")
Appointment.Start = DateAdd("d", 350, Range("b2")) & " " & Time
Appointment.Body = Range("a2") & ", " & Range("b2") & ", " & Range("c2") &
", " & Range("d2") & ", " & Range("e2")
Appointment.ReminderPlaySound = True
Appointment.Display
'Outlook.quit
'Set Outlook = Nothing
End Sub
--
problem
|