Jump to content

excel Destacar datas que correspondam a fins de semana


Recommended Posts

tiagofo20

Boa tarde, eu tenho em excel uma coluna com datas sequênciais, mas as datas podem aparecer repetidas, há maneira das datas que correspondam a fim de semana (exemplo: 21-06-2014 e 22-06-2014) ficarem preenchidas a vermelho?

Se sim, depois é-me possível marcar manualmente a vermelho as datas que correspondam a feriados?

Link to post
Share on other sites
BernasKing

ola,

Sub asd()
Dim meDate As String
Dim meWeekday As Integer
Dim meWeekDayName As String
Dim LastRow As Double
Dim friado(2) As Date
Dim data As Double
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
friado(1) = "07-01-2014"
friado(2) = "08-01-2014"
For data = 1 To LastRow
meDate = Cells(data, 1)
meWeekday = Weekday(meDate)
meWeekDayName = WeekdayName(Weekday(meDate))
If (WeekdayName(Weekday(meDate)) = "sábado") Or _
	(WeekdayName(Weekday(meDate)) = "domingo") Then
		With Cells(data, 1).Font
			.Color = -16776961
		End With
End If
For Each fir In friado
	If Cells(data, 1) = fir Then
			With Cells(data, 1).Font
			 .Color = -16776961
			End With
	End If
Next fir
Next data

End Sub

Edited by BernasKing
Link to post
Share on other sites
ITWare2008

Bom dia,

para preencher os fins-de-semana uma forma rápida de o fazer é seleccionar a coluna das datas e na formatação condiconal escolher a opção nova regra, usar uma fórmula para determinar quais as células a formatar e escrever a seguinte fórmula

=WEEKDAY(G2;2)>=6

ou

=dia.semana(G2;2)>=6

aquele dois como segundo argumento da função indica que os dias da semana vão ser numerados de 1 (segunda) a 7 (domingo) daí o >= 6 (sábado)

Espero ter ajudado.

Vândalo

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.