List Nth item from a range.

Tom.Jones

Well-known Member
Joined
Sep 20, 2011
Messages
509
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. Mobile
Howdy,

I need a UDF to return the nth value from a row or a column.

Ex. I want the 4th item (from left to right) in range A2: P2
or
I want the 5th item (top to down) from range A2: A16

If it were not very complicated, it would be perfect if I had the choice of the opposite, ie from right to left or from bottom to top.

Thank you.
 
Last edited:
An alternative, which does allow indexing outside the range:

Function Nth(r As Range, n As Long) As Range
Set Nth = r.Cells(n)
End Function
That certainly is a bit simpler than what I had, though I got some validations going on in there.
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
To exclude indexing outside the range,

Code:
Function Nth(r As Range, n As Long) As Range
  Set Nth = Intersect(r, r.Cells(n))
End Function
 
Upvote 0
Thank you very much to both of you. Excellent.
 
Upvote 0

Forum statistics

Threads
1,215,544
Messages
6,125,441
Members
449,225
Latest member
mparcado

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