Fill in missing sequential numbers using two value in separate columns

bchi99

Board Regular
Joined
Dec 9, 2014
Messages
56
Office Version
  1. 365
I have a random two-column sheet that I need to list the values between in a single column. The output given the following two columns below should be shown below as well. Anyone with vba knowledge help?

I NEED THIS:

42
43
44
45
46
99
100
102
55
56
57
.
.
.
90
120
121
123
.
.
.
1111
66
67
68
.
.
.
99

Current file is comprised of this original values

4246
99102
5590
1201111
6699
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
This can be done with the new function SEQUENCE. Do you have Excel 365? Your signature in your profile has a place where you can tell others what Excel version you are using.
 
Upvote 0
i have excel 365

I suggest that you update your Account details (or 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’)
 
Upvote 0
i dont' think sequence can take in values already in a sheet, maybe I'm wrong but to I need A1=42, B1=46, A2=55, B2=57 to be:

42
43
44
45
46
55
56
57
 
Last edited:
Upvote 0
I suggest that you update your Account details (or 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’)
thanks just did that
 
Upvote 0
It would be better is you update your profile, rather than put it in your signature. ;)
 
Upvote 0
I might have spoken too soon. It's troublesome to create an array inside SEQUENCE. I can do it per single row, but even then I can't stack the resulting array. PQ or VBA might be necessary. A formula solution might be possible with LAMBDA, but I can't seem to figure it out.
 
Upvote 0
Assuming your values are in A2 & b2 downwards, how about
VBA Code:
Sub bchi()
   Dim Ary As Variant, Nary As Variant, s As Variant
   Dim r As Long, i As Long, nr As Long
   
   Ary = Range("A2:B" & Range("A" & Rows.Count).End(xlUp).Row).Value2
   ReDim Nary(1 To Rows.Count - 2, 1 To 1)
   For r = 1 To UBound(Ary)
      s = Evaluate("row(" & Ary(r, 1) & ":" & Ary(r, 2) & ")")
      For i = 1 To UBound(s)
         nr = nr + 1
         Nary(nr, 1) = s(i, 1)
      Next i
   Next r
   Range("E2").Resize(nr).Value = Nary
End Sub
 
Upvote 0
It can be done with formulas, if you use a few helper columns:

Book1
ABCDEF
1StartEndOffsetRange sizeStartResult
24246054242
399102549443
455909364644
545
646
799
8100
9101
10102
1155
1256
1357
1458
1559
1660
Sheet4
Cell Formulas
RangeFormula
C2:C4C2=SUM(C1:D1)
D2:D4D2=B2-A2+1
E2:E4E2=A2-C2
F2:F46F2=SEQUENCE(SUM(D:D),,0)+VLOOKUP(SEQUENCE(SUM(D:D),,0),C2:E4,3)
Dynamic array formulas.


I think it would be possible to include the helper columns within the formula, but it would be really ugly.
 
Upvote 0

Forum statistics

Threads
1,215,601
Messages
6,125,763
Members
449,259
Latest member
rehanahmadawan

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