Find first TRUE value each week

rongil20

New Member
Joined
Jun 23, 2015
Messages
12
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
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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
 
Upvote 0

Forum statistics

Threads
1,213,524
Messages
6,114,117
Members
448,549
Latest member
brianhfield

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