Find first TRUE value each week

rongil20

New Member
Joined
Jun 23, 2015
Messages
5
Week No
Match
Result
1
FALSE
1
TRUE
YES
1
TRUE
2
TRUE
YES
2
FALSE
2
TRUE
2
FALSE
3
FALSE
3
TRUE
YES
4
FALSE
4
FALSE
4
TRUE
YES
5
TRUE
YES
5
TRUE

<tbody>
</tbody>

Hi, I am trying to find a way to get the third column in the above dataset to find the first TRUE value in each week (which I have manually done myself above).

Obviously I need a macro but no idea where to even begin with this, any help much appreciated.

Thanks
 

Some videos you may like

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
10,144
Try:
Code:
Sub findTrue()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Sheets("Sheet1").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim rng As Range
    Dim rngUniques As Range
    Dim foundVal As Range
    Sheets("Sheet1").Range("A1:A" & LastRow).AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range _
        ("A1:A" & LastRow), Unique:=True
    Set rngUniques = Sheets("Sheet1").Range("A2:A" & LastRow).SpecialCells(xlCellTypeVisible)
    For Each rng In rngUniques
        Range("A1:C" & LastRow).AutoFilter Field:=1, Criteria1:=rng
        Set foundVal = Range("B:B").SpecialCells(xlCellTypeVisible).Find("TRUE")
        If Not foundVal Is Nothing Then
            foundVal.Offset(0, 1) = "YES"
        End If
    Next rng
    If Sheets("Sheet1").AutoFilterMode = True Then Sheets("Sheet1").AutoFilterMode = False
    Application.ScreenUpdating = False
End Sub
 

Tetra201

MrExcel MVP
Joined
Oct 14, 2016
Messages
3,631
... Obviously I need a macro...
Will a formula work for you?
If yes, try placing the following formula in cell C3 and drag-copying it down as needed

=IF(AND(B2,COUNTIFS($A$2:A2,A2,$B$2:B2,TRUE)=1),"YES","")
 

Watch MrExcel Video

Forum statistics

Threads
1,122,911
Messages
5,598,819
Members
414,260
Latest member
joishe

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
Top