AUTO FILTER - can manual row numbers re-number themselves?

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,790
Office Version
  1. 2016
Platform
  1. Windows
I have a project where I have numbered the rows starting at A10 down to A1000. So the numbers go from 1 to 1010. If I auto filter for a certain office and it pulls up 50 rows would it be possible for the row numbers to re-number themselves in column A to show 1 thru 50 for that particular office--and then when the auto filter is removed the numbers would revert back?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Re: AUTO FILTER - possibel to have row numbers "re-numb

I would also be looking Forward to the same thing as desired by em
 
Upvote 0
Re: AUTO FILTER - can manual row numbers re-number themselve

Throwing this back out there...
 
Upvote 0
Re: AUTO FILTER - can manual row numbers re-number themselve

hi there,

sounds like a vba solution may work here, and i can't give you that. but if you want to restructure your data, and assign a count to each individual *account* which adds everytime another entry is produced of the same likeness, maybe something like this...
Book14.xls
ABCD
11Alpha
21Bravo
31Delta
41Echo
52Alpha
63Alpha
74Alpha
82Bravo
95Alpha
106Alpha
113Bravo
121Charlie
132Delta
144Bravo
157Alpha
Sheet5


formula in B2 is:
=IF(ROW()=1,1,IF(B2="","",IF(B2=B1,A1+1,COUNTIF(B$1:B2,B2))))

copy down as far as wanted.

i hope this helps. post back with results.
 
Upvote 0
Re: AUTO FILTER - can manual row numbers re-number themselve

firefytr - that's not exactly what I wanted. Wanted the entire list numbered sequentially so I printed the full list everything would be numbered or if I auto filtered and then printed just that list it would be numbered sequentially...
 
Upvote 0
Try a UDF

Code:
Function xCount(Rng As Range)

Dim Counter     As Long
Dim Cell        As Object

    Application.Volatile
    For Each Cell In Rng
        If Cell.RowHeight > 0 Then
            Counter = Counter + 1
            Else
        End If
    Next
    xCount = Counter

End Function

The in A1 put

=xcount($A$1:A1)

and fill down
 
Upvote 0
Re: AUTO FILTER - can manual row numbers re-number themselve

Can't think of a way to do it automatically when the filter is changed (hiding/unhiding rows cannot directly trigger an event procedure).

But you could put the following code either in a Worksheet_SelectionChange procedure, or in a macro attached to a button :-

Code:
Dim rng As Range, cell As Range, number&
On Error GoTo e
Set rng = Range([A11], [A65536].End(xlUp)).SpecialCells(xlCellTypeVisible)
Application.ScreenUpdating = False
For Each cell In rng
     number = number + 1
     cell = number
Next
Application.ScreenUpdating = True
e: End


NOTE : With DRJ's custom function, after hiding or unhiding rows with the filter, you would need to press Ctrl+Alt+F9 to make the function recalculate.
 
Upvote 0
Re: AUTO FILTER - can manual row numbers re-number themselve

DRJ - plugged in your function and it worked.

Ponsy Nob. - thanks for you code also.

Thanks to both for your solutions, I will be using at least one of them--althought still hoping for a formula fix...
 
Upvote 0
don't think a formula fix is possible in your situation, except by Jacob's UDF function.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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