Help with Identifying Row numbers

Dan Wilson

Well-known Member
Joined
Feb 5, 2006
Messages
546
Office Version
  1. 365
Platform
  1. Windows
Good day. I am running Excel out of Office365 (updated) and Windows 10 (updated). Please excuse the length of this thread. Over the last 15 years of using this Forum, I have discovered that my explanation of a request for help has been lacking in total definition of the problem.
Over the last few years, I have created a Workbook that helps me to control and manipulate the data from my music folder. I produce a weekly Podcast featuring the music from that folder. There are now 3007 songs in the music folder. The workbook is titled “50-69music.xlsm” and has five worksheets. The major worksheet is titled “50-69” and contains 15 Columns of data about the 3007 songs. The other four worksheets are used to count, sort, track and total the data about the songs.
The worksheet titled “50-69” searches the Music folder on my computer and copies elements from the File Properties of the Music folder such as Title, Artist, Year of release, etc. This creates a list of the Music folder in Rows 2 through 3008. Thus, each individual song has its own Row number.
One of the 5 worksheets titled “Alpha” contains formulas that count the number of songs that start with a chosen character. That character can be “A” through “Z”, “1” through “9”, or an open parenthesis. This worksheet also contains formulas to create random selections in specified Row number groups. With the help of this Forum, I can now create random numbers based on an array of numbers from Rows 2 thru 3008.
What I need help with is identifying the Row numbers of songs whose Title (Column A) starts with a chosen character. Since there are 3007 songs in the worksheet, I can manually examine the Row numbers of the songs that start with the character “A”. In the current worksheet that ends up being Rows 33 thru 189. That totals a count of 157 songs. I can then put the number 157 in the Take formula to create 40 random numbers of songs to pick for the podcast.
As the acquisition of songs increases almost weekly, the count of songs starting with a particular character changes and that means the Row numbers will change and will require manually counting the chosen songs to make the Take function work properly.
Is there a function that will identify the first and last Row numbers of songs with a chosen starting character? That will then make the choice of random selection accurate. Thank you for reading this far and for any help with this issue.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Would this work for you (instead of A1:A10 select your array of song names):

Excel Formula:
=TAKE(FILTER(ROW(A1:A10),LEFT(A1:A10,1)="A"),{1,-1})
?
 
Upvote 0
Would this work for you (instead of A1:A10 select your array of song names):

Excel Formula:
=TAKE(FILTER(ROW(A1:A10),LEFT(A1:A10,1)="A"),{1,-1})
?
What is the purpose of TAKE here?

Wouldn't this work just as well?
=FILTER(ROW(A1:A100),LEFT(A1:A100)="A")
 
Upvote 0
One option:
Excel Formula:
=XLOOKUP(TRUE,LEFT(A:A,1)="A",ROW(A:A),,,{1;-1})
 
Upvote 0
Would this work for you (instead of A1:A10 select your array of song names):

Excel Formula:
=TAKE(FILTER(ROW(A1:A10),LEFT(A1:A10,1)="A"),{1,-1})
?
Good day and thank you for the reply. In trying all of the suggested fixes, I have determined that the problem may be incurable. The formulas suggested all relate to the knowledge of the start and finish Cell number. For instance, the first “A” song is in Cell A33 and the last one is in A189. It appears that the only way to determine the start and finish Cells is a manual observation of the worksheet. If no songs were ever added to the “50-69” worksheet, this would not be a problem. If I add only one song starting with an “A” character, the Cell numbers would then become A33 to A190 and I would then have to change all of the created formulas as everything beyond that point would have also changed.
What I need is a function or formula that will search the entire Column A of the “50-69” worksheet and identify the first and last Cell number of songs that start with the chosen character. That will require 36 different formulas to identify the Cell range of each character.
I already have 36 formulas on a worksheet titled “Counts” that identifies the count of how many songs start with each of the 36 characters. These, however, do not identify the Cell numbers. One of those formulas is =SUM(COUNTIF(’50-69’!A:A,{“A*”}))
In reviewing this thread reply, I just realized that the formula listed above will automatically update the count of songs for each starting character. If there is a function that will identify the Cell number of the first song of each character type, I can then merge the two numbers together to make the necessary start and stop numbers.
I will understand if there is no solution to this issue.
 
Upvote 0
What is the purpose of TAKE here?

Wouldn't this work just as well?
=FILTER(ROW(A1:A100),LEFT(A1:A100)="A")
Good day and thank you for the reply. In trying all of the suggested fixes, I have determined that the problem may be incurable. The formulas suggested all relate to the knowledge of the start and finish Cell number. For instance, the first “A” song is in Cell A33 and the last one is in A189. It appears that the only way to determine the start and finish Cells is a manual observation of the worksheet. If no songs were ever added to the “50-69” worksheet, this would not be a problem. If I add only one song starting with an “A” character, the Cell numbers would then become A33 to A190 and I would then have to change all of the created formulas as everything beyond that point would have also changed.
What I need is a function or formula that will search the entire Column A of the “50-69” worksheet and identify the first and last Cell number of songs that start with the chosen character. That will require 36 different formulas to identify the Cell range of each character.
I already have 36 formulas on a worksheet titled “Counts” that identifies the count of how many songs start with each of the 36 characters. These, however, do not identify the Cell numbers. One of those formulas is =SUM(COUNTIF(’50-69’!A:A,{“A*”}))
In reviewing this thread reply, I just realized that the formula listed above will automatically update the count of songs for each starting character. If there is a function that will identify the Cell number of the first song of each character type, I can then merge the two numbers together to make the necessary start and stop numbers.
I will understand if there is no solution to this issue.
 
Upvote 0
One option:
Excel Formula:
=XLOOKUP(TRUE,LEFT(A:A,1)="A",ROW(A:A),,,{1;-1})
Good day and thank you for the reply. In trying all of the suggested fixes, I have determined that the problem may be incurable. The formulas suggested all relate to the knowledge of the start and finish Cell number. For instance, the first “A” song is in Cell A33 and the last one is in A189. It appears that the only way to determine the start and finish Cells is a manual observation of the worksheet. If no songs were ever added to the “50-69” worksheet, this would not be a problem. If I add only one song starting with an “A” character, the Cell numbers would then become A33 to A190 and I would then have to change all of the created formulas as everything beyond that point would have also changed.
What I need is a function or formula that will search the entire Column A of the “50-69” worksheet and identify the first and last Cell number of songs that start with the chosen character. That will require 36 different formulas to identify the Cell range of each character.
I already have 36 formulas on a worksheet titled “Counts” that identifies the count of how many songs start with each of the 36 characters. These, however, do not identify the Cell numbers. One of those formulas is =SUM(COUNTIF(’50-69’!A:A,{“A*”}))
In reviewing this thread reply, I just realized that the formula listed above will automatically update the count of songs for each starting character. If there is a function that will identify the Cell number of the first song of each character type, I can then merge the two numbers together to make the necessary start and stop numbers.
I will understand if there is no solution to this issue.
 
Upvote 0
So, something like this maybe (replace the array A2:A20000 with your actual range to test it; it might actually be better not to select the whole column for calculation reasons; I am still not sure whether you are looking for lowest and highest row number or just their difference, but it is doable):

Excel Formula:
=HSTACK(VSTACK(SEQUENCE(10,,0),CHAR(SEQUENCE(26,,65))),IFERROR(LET(array,A2:A20000,DROP(REDUCE("",VSTACK(TEXT(SEQUENCE(10,,0),0),CHAR(SEQUENCE(26,,65))),LAMBDA(a,b,VSTACK(a,TRANSPOSE(TAKE(FILTER(ROW(array),LEFT(array,1)=b),{1,-1}))))),1)),"not listed"))
 
Upvote 0
Not following what you want but perhaps.
Excel Formula:
=XLOOKUP(CHAR(SEQUENCE(26,,65)),UPPER(LEFT(A:A,1)),ROW(A:A),"",0,{1,-1})
 
Upvote 0
So, something like this maybe (replace the array A2:A20000 with your actual range to test it; it might actually be better not to select the whole column for calculation reasons; I am still not sure whether you are looking for lowest and highest row number or just their difference, but it is doable):

Excel Formula:
=HSTACK(VSTACK(SEQUENCE(10,,0),CHAR(SEQUENCE(26,,65))),IFERROR(LET(array,A2:A20000,DROP(REDUCE("",VSTACK(TEXT(SEQUENCE(10,,0),0),CHAR(SEQUENCE(26,,65))),LAMBDA(a,b,VSTACK(a,TRANSPOSE(TAKE(FILTER(ROW(array),LEFT(array,1)=b),{1,-1}))))),1)),"not listed"))
Good day. Let’s try this one more time. I have a worksheet with File Properties extracted from my music folder containing 3007 songs. The worksheet is titled “50-69” with Column A containing the Title of each song in alphabetic order. Right now there are 157 songs starting with the character “A”. There are 172 songs starting with the character “B” and so on for 36 different characters. The first “A” song is in Row 33 which is identified as Cell A33. The first “B” song is in Row 190 identified as Cell A190.
What I am looking for is a formula or a function that will examine all 3007 songs and show me the first Cell in the worksheet that matches the chosen search character. There will be 36 formulas to do this. I know how many songs there are in each character type, so all I have to do is identify the first Cell found, add the number of songs in that character set, then subtract one (-1) from the total and I will have the first and last Cell number of each character type. I can then run the Random Function to pick 40 random numbers out of the total numbers found. I already have a formula that will create 40 random numbers with no duplications.
I don’t know how to make it any clearer than that. I’m sorry if the last reply caused any confusion.
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,081
Members
453,021
Latest member
Justyna P

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