Count consecutive cells value amount

Vincent88

Active Member
Joined
Mar 5, 2021
Messages
382
Office Version
  1. 2019
Platform
  1. Windows
  2. 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
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKAL
1MDateAttendance27-Oct28-Oct29-Oct30-Oct31-Oct1-Nov2-Nov3-Nov4-Nov5-Nov6-Nov7-Nov8-Nov9-Nov10-Nov11-Nov12-Nov13-Nov14-Nov15-Nov16-Nov17-Nov18-Nov19-Nov20-Nov21-Nov22-Nov23-Nov24-Nov25-Nov26-Nov27-Nov28-Nov29-Nov30-Nov1-Dec
2DateSummary(5)(4)(3)(2)(1)12345678910111213141516171819202122232425262728293031
3Jack ST:22 L:1 D:21 E:0 N:0DDDGGDD2D2GGGGGGALGGGGGGGGGGGGD1
4Gogo MT:22 L:0 D:25 E:0 N:0DDGGGGDDDDDBLDDDDDDDDDDDDDDDDDDGD1
5Pat HT:22 L:0 D:22 E:0 N:0KKD1D2KKKKKKKKGKKKKKKKKKKKKKK
6YummiT:22 L:0 D:23 E:0 N:0D4D4D4PLD3D3D3D3D3DSLD3D3D3D3D3D3D3BLD3D3D3D3D3D3D3D3D3D3AL
7Manus OT:22 L:0 D:6 E:7 N:0ALD3D1DD D D D DSLD D D D D D DDDDDEEEEEEEE
8Pet GT:22 L:1 D:0 E:0 N:22D1D1DNNNNNNNALNNNNNNNNNNNNNNNN
9Gigi TT:22 L:1 D:16 E:8 N:0DDD1DDD3D3D3DEEEEEEEBLDDDDDD1ALD1D1D1DDEN
202111
Cells with Data Validation
CellAllowCriteria
H3:AL9List=ShiftcodeNew
A3:A8List=Data!$U$2:$U$14
A9List=Data!$U$2:$U$8
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,223,886
Messages
6,175,195
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top