![]() |
how many rows since the last time this happened
Row number 1844 column C contains the integer 10.
I want to search back up row C (starting at row 1843) to count how many rows there are between row 1843 and the last time there was a 10 in row C. I would prefer a solution that uses VBA. |
how many rows since the last time this happened
|
how many rows since the last time this happened
On Sunday, May 17, 2015 at 6:33:28 PM UTC+10, wrote:
Row number 1844 column C contains the integer 10. I want to search back up row C (starting at row 1843) to count how many rows there are between row 1843 and the last time there was a 10 in row C. I would prefer a solution that uses VBA. Hi Claus, Thank you. It works beautifully. |
how many rows since the last time this happened
On Sunday, May 17, 2015 at 3:33:28 AM UTC-5, wrote:
Row number 1844 column C contains the integer 10. I want to search back up row C (starting at row 1843) to count how many rows there are between row 1843 and the last time there was a 10 in row C. I would prefer a solution that uses VBA. You may like this better as it fires when you enter a value and will work anywhere in the column '============= Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim tr As Long Dim MF As Range tr = Target.Row If Target.Column < 3 Then Exit Sub Set MF = Columns(3).Find(What:=Target, After:=Cells(tr, 3), LookIn:=xlValues, _ LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _ MatchCase:=False, SearchFormat:=False) If Not MF Is Nothing Then MF.Select MsgBox "Row " & Abs(MF.Row) End If End Sub |
All times are GMT +1. The time now is 05:15 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com