Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete rows if time is greater than present time Sabosis Excel Programming 2 January 14th 13 02:12 PM
Transpose 4 Columns data to Rows for Employee Time In and Time Out Schedule Nasir[_2_] Excel Programming 0 May 4th 11 12:05 PM
what happened linda Excel Worksheet Functions 1 August 6th 07 10:26 PM
How can I calculate events that happened at the same time? Stuboy28 Excel Discussion (Misc queries) 2 February 28th 07 09:06 PM
what happened WYN Excel Discussion (Misc queries) 1 October 11th 06 06:39 PM


All times are GMT +1. The time now is 01:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"