Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

return line number

Forum home » Delegate support and help forum » Microsoft Excel Training and help » return line number within a range

return line number within a range

ResolvedVersion 365

Chris has attended:
Excel Advanced course
Excel VBA Intro Intermediate course
Excel Intermediate course
Excel Dashboards for Business Intelligence course
Advanced Excel Dashboards course
Excel PowerPivot course
Excel Advanced - Formulas & Functions course
Excel Charting course

return line number within a range

I am trying to find a formula to put into column C to return the line line of a contract line item within the range of Customer ID (Row B). See desired result in row D. Thank you.

Customers ID Contract line No Contract line No desired result
6978 1
6978 2
6978 3
6978 4
6978 5
6978 6
6978 7
6979 1
6980 1
6981 1
6982 1
11081 1
11505 1
11557 1
14203 1
14614 1
14769 1
14944 1
14945 1
14946 1
15601 1
16006 1

RE: return line number within a range

Hi Chris,

Thank you for the forum question.

If you have column B sorted ascending or descending try:




=IF(B1=B2,C1+1,1)


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: return line number within a range

Hi Chris,

Or even better (now column B doesn't need to be sorted)

=COUNTIF($B$2:B2,B2)



Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Excel tip:

Formst Excel to display leading zeroes

Select the cells that you want to have displaying leading zeroes.

From the 'Format' menu select 'Cells' (Or Right-click on the selected range and and select 'Format Cells').

In the 'Number' tab click on 'Custom' in the 'Category' window.

In the 'Type:' box enter zeroes that correspond to the size of the required number (eg 5 zeroes).

Click OK.

When you enter numbers into these cells, leading zeroes will be displayed.

eg 123 = 00123

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.