Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- Mobile
Hi, I want to have a vba code to count any consecutive cells in each row with the sum of any arraylist values over 5 then underline those consecutive values.
VBA Code:
Sub highlightCells()
Dim ws As Worksheet
Set ws = ActiveSheet
Dim lastrow As Long
lastrow = Range("A2").End(xlDown).Row
Dim L as Long, M as Long, F as Long
L = Application.Match(CLng(DateSerial(Year(.Range("C1").Value), Month(.Range("C1").Value) + 1, 0)) - 4, .Rows(1), 0) 'Column of the Last Fifth day of last month
M = Application.Match(CLng(DateSerial(Year(.Range("C1").Value), Month(.Range("C1").Value) + 1, 0)) + 1, .Rows(1), 0) 'Column of the First day of the month
'The column where the last day of the month is
F = Application.Match(CLng(DateSerial(Year(.Cells(1, M).Value), Month(.Cells(1, M).Value) + 1, 0)), .Rows(1), 0) 'Column of the Last day of the month
Debug.Print L, M, F
Dim wArray As Variant
wArray = Array("D1", "D2", "D3", "D4", "E", "G", "K", "N", "AM", "PM")
Dim rngData As Range
Set rngData = Range("A3",cells(F, lastrow))
AgentProposal_Roster0728_0402C.xlsm | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | AA | AB | AC | AD | AE | AF | AG | AH | AI | AJ | AK | AL | |||
1 | MDate | Attendance | 27-Oct | 28-Oct | 29-Oct | 30-Oct | 31-Oct | 1-Nov | 2-Nov | 3-Nov | 4-Nov | 5-Nov | 6-Nov | 7-Nov | 8-Nov | 9-Nov | 10-Nov | 11-Nov | 12-Nov | 13-Nov | 14-Nov | 15-Nov | 16-Nov | 17-Nov | 18-Nov | 19-Nov | 20-Nov | 21-Nov | 22-Nov | 23-Nov | 24-Nov | 25-Nov | 26-Nov | 27-Nov | 28-Nov | 29-Nov | 30-Nov | 1-Dec | ||
2 | Date | Summary | (5) | (4) | (3) | (2) | (1) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | ||
3 | Jack S | T:22 L:1 D:21 E:0 N:0 | D | D | D | G | G | D | D2 | D2 | G | G | G | G | G | G | AL | G | G | G | G | G | G | G | G | G | G | G | G | D1 | ||||||||||
4 | Gogo M | T:22 L:0 D:25 E:0 N:0 | D | D | G | G | G | G | D | D | D | D | D | BL | D | D | D | D | D | D | D | D | D | D | D | D | D | D | D | D | D | D | G | D1 | ||||||
5 | Pat H | T:22 L:0 D:22 E:0 N:0 | K | K | D1 | D2 | K | K | K | K | K | K | K | K | G | K | K | K | K | K | K | K | K | K | K | K | K | K | K | |||||||||||
6 | Yummi | T:22 L:0 D:23 E:0 N:0 | D4 | D4 | D4 | PL | D3 | D3 | D3 | D3 | D3 | D | SL | D3 | D3 | D3 | D3 | D3 | D3 | D3 | BL | D3 | D3 | D3 | D3 | D3 | D3 | D3 | D3 | D3 | D3 | AL | ||||||||
7 | Manus O | T:22 L:0 D:6 E:7 N:0 | AL | D3 | D1 | D | D | D | D | D | D | SL | D | D | D | D | D | D | D | D | D | D | D | E | E | E | E | E | E | E | E | |||||||||
8 | Pet G | T:22 L:1 D:0 E:0 N:22 | D1 | D1 | D | N | N | N | N | N | N | N | AL | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | |||||||||||
9 | Gigi T | T:22 L:1 D:16 E:8 N:0 | D | D | D1 | D | D | D3 | D3 | D3 | D | E | E | E | E | E | E | E | BL | D | D | D | D | D | D1 | AL | D1 | D1 | D1 | D | D | E | N | |||||||
202111 |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
H3:AL9 | List | =ShiftcodeNew |
A3:A8 | List | =Data!$U$2:$U$14 |
A9 | List | =Data!$U$2:$U$8 |