find row No

Excel777

Well-known Member
Joined
Jul 3, 2009
Messages
914
Office Version
  1. 2019
i want to find row no of -1
results is column D
Excel Workbook
ABCD
1DataNumberRow
2-1-12
31-16
4-6-18
55-112
6-1-114
71
8-1
94
10-2
111
12-1
131
14-1
Sheet2
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Code:
Sub chuckles1066()

Dim lr As Long
Dim a As Long
Dim b As Long

lr = Range("A" & Rows.Count).End(xlUp).Row
b = 2
For a = 2 To lr
Select Case Cells(a, 1).Value
    Case -1
        Cells(b, 3).Value = Cells(a, 1).Value
        Cells(b, 4).Value = a
        b = b + 1
End Select
Next
End Sub
 
Last edited:
Upvote 0
need a formula to drag down
Try this...

Book1
ABCD
1Data_NumberRow
2-1_-12
31_Count6
4-6_58
55__12
6-1__14
71__
8-1__
94__
10-2__
111__
12-1__
131__
14-1__
Sheet1

Enter this formula in C4 to get the count of records that meet the criteria:

=COUNTIF(A:A,C2)

Enter this array formula** in D2 to return the row numbers:

=IF(ROWS(D$2:D2)>C$4,"",SMALL(IF(A$2:A$14=C$2,ROW(A$2:A$14)),ROWS(D$2:D2)))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

Copy down until you get blanks.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,876
Members
452,949
Latest member
Dupuhini

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