2014-01-23 8 views
-1

지금까지 매크로를 사용하여 Excel 목록에있는 모든 사람에게 전자 메일을 보내고 있습니다. 몇 가지 더 추가해야 할 경우를 제외하고는 제대로 작동합니다.VBA의 내용을 건너 뛰는 방법

1, 날짜가 세포 (r, 4) 인 경우에만 사람에게 전자 메일을 보냅니다. 값은 오늘 +7 일과 오늘 +14 일 사이에 있으면 그 행을 건너 뜁니다. "거짓"

3 "참"으로 행 스킵의 세포 (R 20) .Value

2 이메일이 전송 된 경우 변경 값 세포이다 (R 20) .Value는 지금까지 것처럼 보이는데 Heres는 방법

"참":

Sub SetupAppointmentList() 
' adds a list of appontments to the Calendar in Outlook 
Dim olApp As Outlook.Application 
Dim olAppItem As Outlook.AppointmentItem 
Dim r As Long 
    DeleteNotices ' deletes previous test appointments 
    On Error Resume Next 
    Set olApp = GetObject("", "Outlook.Application") 
    On Error GoTo 0 
    If olApp Is Nothing Then 
     On Error Resume Next 
     Set olApp = CreateObject("Outlook.Application") 
     On Error GoTo 0 
     If olApp Is Nothing Then 
      MsgBox "Outlook is not available!" 
      Exit Sub 
     End If 
    End If 




    r = 10 ' first row with data in 
    While Len(Cells(r, 1).Formula) > 0 
     Set olAppItem = olApp.CreateItem(olAppointmentItem) 
     With olAppItem 

      .MeetingStatus = olMeeting 
      ' set default appointment values 
      .Start = Now 
      .End = Now 
      .Subject = "No subject" 
      .Location = "" 
      .Body = "" 
      .ReminderSet = True 
      On Error Resume Next 
      .Recipients.Add Cells(r, 3).Value 
      .Recipients.ResolveAll 
      .Start = Cells(r, 4).Value + Cells(r, 5).Value 
      .End = Cells(r, 4).Value + Cells(r, 6).Value 
      .Subject = "Interview" 
      .Location = Cells(r, 13).Value + ", " + Cells(r, 14).Value 
      .Body = "Hi.... Blah Blah Blah" 
      .ReminderMinutesBeforeStart = 30 
      .Categories = "Notice"    
    On Error GoTo 0 
      .Save 
      .Display 
      '.Send 


     End With 
     r = r + 1 
    Wend 
    Set olAppItem = Nothing 
    Set olApp = Nothing 
End Sub 

당신이 도와 수 있기를 바랍니다, 미리 감사드립니다!

답변

0

여기에 당신이 무엇을 위해 코드를 작성하는 대신 :

는 세포의 콘텐츠를 (R, 4) 날짜로 변환에서는 CDate를 사용합니다. 시작 날짜 및 종료 날짜와 비교하고 범위 내에있는 경우 계속하십시오.

(r, 20)의 내용을 가져 와서 CBool을 사용하여 bool 값을 가져옵니다. 확인하고 계속 진행할 것인지 확인하십시오.

이메일, 단지 설정 세포를 보낸 후 (r은, 20)

가 시도하고 그것이 어떻게되는지 진정한 =.

+0

고마워, 메신저 여전히 아주 새로운 물건을 보냈습니다. Im는 아닙니다 entirly 어떻게 또는 어디에서 나의 부호에서 이것을 두어야하는지 확인하십시오. – Rardo

관련 문제