Guest User

Untitled

a guest
Jan 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. Function IsWeekendDay(monthRange As Range)
  2.  
  3. Dim DayNum As Variant
  4. Dim IsWeekend As Boolean
  5. Dim s As String
  6. Dim cell As Range
  7. Set currentsheet = ActiveWorkbook.ActiveSheet
  8. Dim CellsDown As Long
  9. Dim CurVal As String
  10. Dim index As Integer
  11. Dim CurCol As Integer
  12.  
  13. index = 44
  14. CurCol = 0
  15. CellsDown = 21
  16. CurVal = "W"
  17.  
  18.  
  19.  
  20.  
  21. For Each cell In monthRange
  22. DayNum = WorksheetFunction.Weekday(cell.Value, vbSunday)
  23. If Not IsError(DayNum) Then
  24. Select Case DayNum
  25. Case 2 To 6 ' Monday thru Friday
  26. IsWeekend = False
  27. cell.Interior.ColorIndex = 2
  28. Case Else
  29. IsWeekend = True
  30. cell.Interior.ColorIndex = 44
  31. For CurrRow = 2 To CellsDown
  32. If (Range(cell.Address).Offset(CurrRow -1 ,CurCol).Interior.ColorIndex = 2) Then
  33. Range(cell.Address).Offset(CurrRow - 1, CurCol).Clear
  34. Range(cell.Address).Offset(CurrRow - 1, CurCol).BorderAround (xlContinuous)
  35. Range(cell.Address).Offset(CurrRow - 1, CurCol).Value = CurVal
  36. Range(cell.Address).Offset(CurrRow - 1, CurCol).Interior.ColorIndex = index
  37. End If
  38. Next CurrRow
  39. End Select
  40. Else
  41. IsWeekend = False ' error
  42. End If
  43. Next cell
Add Comment
Please, Sign In to add comment