Need help finding the list of alphabets between two letters

tamtammg

New Member
Joined
Oct 15, 2020
Messages
8
Hello everyone,

I need some help creating a VBA code to list the alphabets (in order) between two letters. Something like this:

GetLetters(A1,B1) -> bcdefg

A1 = b
B1 = g

Is there a way to show the string 'bcdefg' in one cell? Please see the attached image.

Thank you guys in advance!
 

Attachments

  • Capture.GIF
    Capture.GIF
    6 KB · Views: 6

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
assuming they are all lowercase and A1 and B1 are in alphabetic order, you could use say F1 to hold the characters from a-z and use the following
Book1
ABCDEF
1bgbcdefgabcdefghijklmnopqrstuvwxyz
Sheet1
Cell Formulas
RangeFormula
C1C1=MID(F1,FIND(A1,F1),FIND(B1,F1)-FIND(A1,F1)+1)
 
Upvote 0
Solution
Hi & welcome to MrExcel.
as long as both characters are the same case, how about
VBA Code:
Function tamtammg(FirstLet As String, LastLet As String) As String
   Dim i As Long
   
   For i = Asc(FirstLet) To Asc(LastLet)
      tamtammg = tamtammg + Chr(i)
   Next i
End Function
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
In case you are interested, another formula approach (IF you have Excel 365** with the SEQUENCE function) is shown below.

** I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

20 10 17.xlsm
ABC
1bgbcdefg
Letter sequence
Cell Formulas
RangeFormula
C1C1=CONCAT(CHAR(SEQUENCE(CODE(B1)-CODE(A1)+1,,CODE(A1))))
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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