Help with Identifying Row numbers

Dan Wilson

Well-known Member
Joined
Feb 5, 2006
Messages
536
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.
 
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})
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

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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.
Did you actually test the formula or not? It is supposed to be 1 formula for 26 letters and 10 numbers at once, i.e. it should return starting and ending row numbers of every character; if it does not work, fine, if it does work but does not return exactly what you want please post what should be adjusted.
 
Upvote 0
Solution
I'll give my last attempt. If you want just to pick random 40 songs from the list, you don't need the location.
Book1
ABCDEFGH
1Song TitlesCharacterFirst RowLast RowRandom 40 songs starts with:A
2A Thousand MilesA241Adore You
3All of MeB42106Anything for You
4American PieC107111A Change Is Gonna Come
5A Sky Full of StarsDAnother Brick in the Wall
6AfricaEAngel
7AlwaysFAdventure of a Lifetime
8All You Need Is LoveGAin't No Mountain High Enough
9Ain't No Mountain High EnoughHAll I Want for Christmas Is You
10ApologizeIAfterglow
11All About That BassJAttention
12AliveKAin't No Sunshine
13AngelLAll Apologies
14Ain't It FunMAt Last
15Adore YouNAlways
16All I WantOAnarchy in the U.K.
17Another Brick in the WallPAll of Me
18Ain't No SunshineQA Thousand Miles
19AttentionRArms
20As Long as You Love MeSAll the Right Moves
21Another One Bites the DustTA Sky Full of Stars
22All StarUAs Long as You Love Me
23And I Love HerVAin't It Fun
24At LastWAlready Gone
25All the Small ThingsXAnother Love
26Anarchy in the U.K.YAddicted to Love
27A Hard Day's NightZAmerican Pie
28Addicted to LoveAm I Wrong
29All My LifeAll Star
30ArmsAnother One Bites the Dust
31Achy Breaky HeartAll the Small Things
32Already GoneAlive
33Another LoveAchy Breaky Heart
34Anything for YouAll My Life
35A Change Is Gonna ComeA Hard Day's Night
36All ApologiesApologize
37All I Want for Christmas Is YouAnd I Love Her
38Am I WrongAll You Need Is Love
39AfterglowAll About That Bass
40All the Right MovesAll I Want
41Adventure of a LifetimeAfrica
42Bad Romance
43Blue Suede Shoes
44Born to Be Wild
45Beat It
46Brown Sugar
47Blueberry Hill
48Black Hole Sun
49Bridge Over Troubled Water
50Because You Loved Me
51Big Girls Don't Cry
52Beautiful
53Blame It on the Boogie
54Breakfast at Tiffany's
55Bad Blood
56Bulletproof
57Burn
58Baba O'Riley
59Back to Black
60Best of You
61Bubbly
62Barracuda
63Bye Bye Bye
64Boogie Wonderland
65Bring the Noise
66Budapest
67Born This Way
68Blurred Lines
69Boys Don't Cry
70Bang Bang
71Black Velvet
72Bad to the Bone
73Blue Ain't Your Color
74Black or White
75Burning Down the House
76Believe
77Bang a Gong (Get It On)
78Bring Me the Horizon
79Body and Soul
80Brave
81Back for Good
82Bright
83Best Day of My Life
84Black Betty
85Bitter Sweet Symphony
86Break Your Heart
87Bleeding Love
88Born in the U.S.A.
89Build Me Up Buttercup
90Bangarang
91Brass in Pocket
92Bad Guy
93Bohemian Rhapsody
94Billie Jean
95Blinding Lights
96Blackbird
97Back in Black
98Born to Run
99Beautiful Day
100Baby One More Time
101Bennie and the Jets
102Basket Case
103Black Magic Woman
104Break Free
105Brown Eyed Girl
106Bring Me to Life
107California Dreamin'
108Come Together
109Closer
110Can't Stop the Feeling!
111Crazy in Love
Sheet5
Cell Formulas
RangeFormula
C2:E27C2=LET(s,CHAR(SEQUENCE(26,,65)),HSTACK(s,XLOOKUP(s,LEFT(UPPER(A2:A111),1),ROW(A2:A111),"",0,{1,-1})))
G2:G41G2=LET(f,FILTER(A2:A111,LEFT(UPPER(A2:A111),1)=H1),TAKE(SORTBY(f,RANDARRAY(ROWS(f))),40))
Dynamic array formulas.
 
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})
Thank you for all your help. I give up. It's not worth all this trouble. I'll do it the hard way.
 
Upvote 0
Did you actually test the formula or not? It is supposed to be 1 formula for 26 letters and 10 numbers at once, i.e. it should return starting and ending row numbers of every character; if it does not work, fine, if it does work but does not return exactly what you want please post what should be adjusted.
Thank you for all your help. I give up. It's not worth all this trouble. I'll do it the hard way. I marked this as complete.
 
Upvote 0
I'll give my last attempt. If you want just to pick random 40 songs from the list, you don't need the location.
Book1
ABCDEFGH
1Song TitlesCharacterFirst RowLast RowRandom 40 songs starts with:A
2A Thousand MilesA241Adore You
3All of MeB42106Anything for You
4American PieC107111A Change Is Gonna Come
5A Sky Full of StarsDAnother Brick in the Wall
6AfricaEAngel
7AlwaysFAdventure of a Lifetime
8All You Need Is LoveGAin't No Mountain High Enough
9Ain't No Mountain High EnoughHAll I Want for Christmas Is You
10ApologizeIAfterglow
11All About That BassJAttention
12AliveKAin't No Sunshine
13AngelLAll Apologies
14Ain't It FunMAt Last
15Adore YouNAlways
16All I WantOAnarchy in the U.K.
17Another Brick in the WallPAll of Me
18Ain't No SunshineQA Thousand Miles
19AttentionRArms
20As Long as You Love MeSAll the Right Moves
21Another One Bites the DustTA Sky Full of Stars
22All StarUAs Long as You Love Me
23And I Love HerVAin't It Fun
24At LastWAlready Gone
25All the Small ThingsXAnother Love
26Anarchy in the U.K.YAddicted to Love
27A Hard Day's NightZAmerican Pie
28Addicted to LoveAm I Wrong
29All My LifeAll Star
30ArmsAnother One Bites the Dust
31Achy Breaky HeartAll the Small Things
32Already GoneAlive
33Another LoveAchy Breaky Heart
34Anything for YouAll My Life
35A Change Is Gonna ComeA Hard Day's Night
36All ApologiesApologize
37All I Want for Christmas Is YouAnd I Love Her
38Am I WrongAll You Need Is Love
39AfterglowAll About That Bass
40All the Right MovesAll I Want
41Adventure of a LifetimeAfrica
42Bad Romance
43Blue Suede Shoes
44Born to Be Wild
45Beat It
46Brown Sugar
47Blueberry Hill
48Black Hole Sun
49Bridge Over Troubled Water
50Because You Loved Me
51Big Girls Don't Cry
52Beautiful
53Blame It on the Boogie
54Breakfast at Tiffany's
55Bad Blood
56Bulletproof
57Burn
58Baba O'Riley
59Back to Black
60Best of You
61Bubbly
62Barracuda
63Bye Bye Bye
64Boogie Wonderland
65Bring the Noise
66Budapest
67Born This Way
68Blurred Lines
69Boys Don't Cry
70Bang Bang
71Black Velvet
72Bad to the Bone
73Blue Ain't Your Color
74Black or White
75Burning Down the House
76Believe
77Bang a Gong (Get It On)
78Bring Me the Horizon
79Body and Soul
80Brave
81Back for Good
82Bright
83Best Day of My Life
84Black Betty
85Bitter Sweet Symphony
86Break Your Heart
87Bleeding Love
88Born in the U.S.A.
89Build Me Up Buttercup
90Bangarang
91Brass in Pocket
92Bad Guy
93Bohemian Rhapsody
94Billie Jean
95Blinding Lights
96Blackbird
97Back in Black
98Born to Run
99Beautiful Day
100Baby One More Time
101Bennie and the Jets
102Basket Case
103Black Magic Woman
104Break Free
105Brown Eyed Girl
106Bring Me to Life
107California Dreamin'
108Come Together
109Closer
110Can't Stop the Feeling!
111Crazy in Love
Sheet5
Cell Formulas
RangeFormula
C2:E27C2=LET(s,CHAR(SEQUENCE(26,,65)),HSTACK(s,XLOOKUP(s,LEFT(UPPER(A2:A111),1),ROW(A2:A111),"",0,{1,-1})))
G2:G41G2=LET(f,FILTER(A2:A111,LEFT(UPPER(A2:A111),1)=H1),TAKE(SORTBY(f,RANDARRAY(ROWS(f))),40))
Dynamic array formulas.
Thank you for all your help. I give up. It's not worth all this trouble. I'll do it the hard way.
 
Upvote 0

Forum statistics

Threads
1,223,939
Messages
6,175,533
Members
452,652
Latest member
eduedu

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