wilg
06-25-2011, 06:04 AM
Hi guys, need some help with the following code. I have a calendar over 2 years. I use this code 24 times....
Is there a way to modify it just to loop?
It starts at row 10 and skips every 4 rows.
For i = 2 To 32
'january
If Cells(10, i).Value = "PU" Or Cells(10, i).Value = "PP" Or Cells(10, i).Value = "F" Or Cells(10, i).Value = "pu" Or Cells(10, i).Value = "pp" Or Cells(10, i).Value = "f" Then
Email_Body = Email_Body & vbNewLine & Format(Cells(8, i).Value, "dddd mmmm d, yyyy = ") & Cells(10, i).Value & " - " & Cells(11, i).Value
End If
Next i
.Body = Email_Body
If Range("ah8") + Range("ai8") + Range("al8") > 0 Then
Email_Body = Email_Body & vbNewLine
End If
.Body = Email_Body
For i = 2 To 32
'february
If Cells(14, i).Value = "PU" Or Cells(14, i).Value = "PP" Or Cells(14, i).Value = "F" Or Cells(14, i).Value = "pu" Or Cells(14, i).Value = "pp" Or Cells(14, i).Value = "f" Then
Email_Body = Email_Body & vbNewLine & Format(Cells(12, i).Value, "dddd mmmm d, yyyy = ") & Cells(14, i).Value & " - " & Cells(15, i).Value
End If
Next i
.Body = Email_Body
If Range("ah12") + Range("ai12") + Range("al12") > 0 Then
Email_Body = Email_Body & vbNewLine
End If
.Body = Email_Body
Is there a way to modify it just to loop?
It starts at row 10 and skips every 4 rows.
For i = 2 To 32
'january
If Cells(10, i).Value = "PU" Or Cells(10, i).Value = "PP" Or Cells(10, i).Value = "F" Or Cells(10, i).Value = "pu" Or Cells(10, i).Value = "pp" Or Cells(10, i).Value = "f" Then
Email_Body = Email_Body & vbNewLine & Format(Cells(8, i).Value, "dddd mmmm d, yyyy = ") & Cells(10, i).Value & " - " & Cells(11, i).Value
End If
Next i
.Body = Email_Body
If Range("ah8") + Range("ai8") + Range("al8") > 0 Then
Email_Body = Email_Body & vbNewLine
End If
.Body = Email_Body
For i = 2 To 32
'february
If Cells(14, i).Value = "PU" Or Cells(14, i).Value = "PP" Or Cells(14, i).Value = "F" Or Cells(14, i).Value = "pu" Or Cells(14, i).Value = "pp" Or Cells(14, i).Value = "f" Then
Email_Body = Email_Body & vbNewLine & Format(Cells(12, i).Value, "dddd mmmm d, yyyy = ") & Cells(14, i).Value & " - " & Cells(15, i).Value
End If
Next i
.Body = Email_Body
If Range("ah12") + Range("ai12") + Range("al12") > 0 Then
Email_Body = Email_Body & vbNewLine
End If
.Body = Email_Body