Boa noite!!!
Essa rotina deve ficar dentro da corpo de edição da planilha!!
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$3" Then
Call Formatacao_Dia
End If: End Sub
As duas de baixo coloque dentro de um módulo
Sub Formatacao_Dia(): Dim Month As String, D As Integer, LDI As Date
Dim S As String, Frq As Integer
Dim i As Long, j As Long, k As Long
Month = Cells(1, "C"): Frq = Cells(3, "C"): LDI = Cells(3, 2)
D = Day(LDI)
i = Range("1:1").Find(Month, Cells(1, 3)).Column - 1
S = GetAlpha(i): j = i + D
For i = 0 To (Frq) ^ 2 Step Frq
Cells(3, j + i).Select
Cells(3, j + i).Interior.ColorIndex = 3
Next i
End Sub
Sub Visivel()
ActiveSheet.Columns.Hidden = False
End Sub
Function GetAlpha(n As Long) As String
Dim Alpha: Dim M As Long
If n > 26 ^ 3 Then Exit Function
Alpha = Array(" ", "A", "B", "C", "D", "E", "F", "G", _
"H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", _
"R", "S", "T", "U", "V", "W", "X", "Y", "Z")
If n > 676 Then
M = n Mod 676
GetAlpha = Alpha(Int(n / 676)) & GetAlpha(M)
ElseIf n > 26 Then
GetAlpha = Alpha(Int(n / 26)) & Alpha(n Mod 26)
Else
GetAlpha = Alpha(n)
End If
..Faça os testes
Importante:
Considere que mudou para a data desejada em B2; depois altere a validação e somente então digite o número de frequência!!!
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 26/07/2012 5:32 pm