List Nth item from a range.

Tom.Jones

Well-known Member
Joined
Sep 20, 2011
Messages
524
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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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