I implemented this now

Private Sub corrermac()
Sheets("Datas").Select
If Range("B1").Value = Range("C1").Value Then
Call julho
ElseIf Range("B2").Value = Range("C2").Value Then
Call agosto
End Sub
Sub julho()
Sheets("Dias acidente").Select
Range("B2:B32").Select
Selection.ClearContents
Sheets("Dias acidente").Select
End Sub
Sub agosto()
Sheets("Dias acidente").Select
Range("B2:B32").Select
Selection.ClearContents
Sheets("Dias acidente").Select
End Sub

in order to delete the days of the past month and so the vlookup to "clear"
the colors and start from 1 again

Any suggestion to a more precise and clean code? thank you

2012/7/12 Jorge Marques <[email protected]>

> Hi guys,
>
> I have this macro I´ve made with a vlookup that one of you kindly help, I
> then developed a macro to everyday put a "Sim" in a scheduled time, and put
> the color green on the correspondent day and if "Não" puts red color, but I
> have a problem.
>
>
> The vlookup conditional formatting doesn´t work if I have numbers
> duplicated.
>
> How can i reset the colors when it starts a new month without having to
> delete the contents of cells B1 to B33 in order to start a again the
> calendar in sheet1? I could do a sort of if month(today()) = 7 then delete
> range(B1:B33) elseif month(today()) = 8 then range (B34:B63) delete, but
> this is coding too much for unnecessary lines, is there a way to do this
> and simplifying? Another think I thought is doing a vlookup of
> (monthtoday()).
>
> Thank you very much in advance
>
> My macro for this is:
>
> Sub acidentes()
>
> Dim RunTime2 As Date
>
> Sheets("Dias acidente").Select
>
> Cells(1, 7).Value = Cells(1, 7) + 1
>
> RunTime2 = Now + TimeValue("00:00:10")
>
> Application.OnTime RunTime2, "acidentes"
>
> Cells(1, 3).End(xlDown).Offset(1, 0).Select
> Selection.Value = "Sim"
>
> For i = 1 To 550
>
> If Cells(i, 3).Value = "Sim" Then
>
>     Cells(i, 4).Value = "Sem acidente"
>     Cells(i, 4).Interior.ColorIndex = 4
>
> ElseIf Cells(i, 3).Value = "Não" Then
>
>     Cells(i, 4).Value = "Com Acidente"
>     Cells(i, 4).Interior.ColorIndex = 3
>     Cells(i, 3).Value = "CA"
>     Cells(1, 7).Value = Cells(1, 7).Value - 1
>
>     Cells(1, 8).Value = Cells(1, 7).Value
>     Cells(1, 7).Value = 0
> End If
> Next
>
> If Range("H13").Value = "stop" Then
> Application.OnTime RunTime2, "acidentes", , False
> End If
> End Sub
>
> --
> FORUM RULES (986+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to [email protected]
>
> To unsubscribe, send a blank email to
> [email protected]

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to [email protected]

To unsubscribe, send a blank email to [email protected]

Reply via email to