Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function IsWeekendDay(monthRange As Range)
- Dim DayNum As Variant
- Dim IsWeekend As Boolean
- Dim s As String
- Dim cell As Range
- Set currentsheet = ActiveWorkbook.ActiveSheet
- Dim CellsDown As Long
- Dim CurVal As String
- Dim index As Integer
- Dim CurCol As Integer
- index = 44
- CurCol = 0
- CellsDown = 21
- CurVal = "W"
- For Each cell In monthRange
- DayNum = WorksheetFunction.Weekday(cell.Value, vbSunday)
- If Not IsError(DayNum) Then
- Select Case DayNum
- Case 2 To 6 ' Monday thru Friday
- IsWeekend = False
- cell.Interior.ColorIndex = 2
- Case Else
- IsWeekend = True
- cell.Interior.ColorIndex = 44
- For CurrRow = 2 To CellsDown
- If (Range(cell.Address).Offset(CurrRow -1 ,CurCol).Interior.ColorIndex = 2) Then
- Range(cell.Address).Offset(CurrRow - 1, CurCol).Clear
- Range(cell.Address).Offset(CurrRow - 1, CurCol).BorderAround (xlContinuous)
- Range(cell.Address).Offset(CurrRow - 1, CurCol).Value = CurVal
- Range(cell.Address).Offset(CurrRow - 1, CurCol).Interior.ColorIndex = index
- End If
- Next CurrRow
- End Select
- Else
- IsWeekend = False ' error
- End If
- Next cell
Add Comment
Please, Sign In to add comment