Numbers between "Start" and "End" sequence

Status
Not open for further replies.

freshgoblinmilk

New Member
Joined
Nov 7, 2022
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
A is the smallest value of a sequence
B is the largest value of a sequence
What I want if for C to show all numbers that fit in that range

1682342940884.png


I am hoping that this way I can easily find duplicated entries beteen 2 tabs.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi there

You can try the following formula perhaps?

Book1
ABC
1StartEndRange
2181,2,3,4,5,6,7,8
39119,10,11
4121212
5131313
6142114,15,16,17,18,19,20,21
Sheet1
Cell Formulas
RangeFormula
C2:C6C2=TEXTJOIN(",",TRUE,IF(ROW(INDIRECT(A2&":"&B2))>0,ROW(INDIRECT(A2&":"&B2)),""))


This I think will only work if you have the numbers as given. Will the numers from Start to End ever change?
 
Upvote 0
The OP doesn't have Textjoin, as that only appeared with 2019. ;)
 
Upvote 0
Hi Fluff

I keep forgetting to check that🙈🙈😫... Apologies to OP...
 
Upvote 0
I am hoping that this way I can easily find duplicated entries between 2 tabs.
If you are actually still on 2016, I suspect you will need code, since you don't have any of the good text functions. Is code an option for you?
 
Upvote 0
One possibility:

VBA Code:
Function ListNumbers(startNum As Long, endNum As Long, Optional sep As String = ",") As String
   Dim OutNums() As String
   ReDim OutNums(startNum To endNum)
   Dim ctr As Long
   For ctr = startNum To endNum
      OutNums(ctr) = ctr
   Next ctr
   ListNumbers = Join(OutNums, sep)
   
End Function

Used like:

Excel Formula:
=ListNumbers(A2,B2)
 
Upvote 0
Since 2016 is not having Textjoin function, UDF is alternative.
Code for UDF
VBA Code:
Function GetNumbers(St As Long, Nd As Long)
Dim temp, T&
If St <> "" And Nd <> "" Then
For T = St To Nd
temp = temp & ", " & T
Next T
End If
If temp <> "" Then GetNumbers = Mid(temp, 3)
End Function
How to Use UDF code:
In the developer tab click--> Visual Basic
VB window opens
Insert--> Module
Paste the code.
Close the VB window.
Now UDF is available in Function List
Save file as .xlsm
In C2 then copied down.
=GetNumbers(A2,B2)
 
Upvote 0
@freshgoblinmilk , What kind of duplicates are you looking for? There may be other ways to do this other than by comparing concatenations? Can you post some examples of the data each each tab using the xl2bb add in (link below)? Sanitize your data before posting
 
Upvote 0
Correction to Post#7
VBA Code:
Function GetNumbers(St As Range, Nd As Range)
Dim temp, T&
If St <> "" And Nd <> "" Then
For T = St To Nd
temp = temp & ", " & T
Next T
End If
If temp <> "" Then GetNumbers = Mid(temp, 3)
End Function
 
Upvote 0
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,907
Messages
6,122,183
Members
449,071
Latest member
cdnMech

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