Creating lists of numbers

Smiler2018

New Member
Joined
Sep 15, 2018
Messages
2
I have a list of no’s and I want to be able to create a list for each line in my table
E.g
Branch, sub dept, start no, end no
1234, 1, 5, 9
4567, 3, 45, 55
8734, 7, 23, 35
Etc

So I need an output of
1234.1.5
1234.1.6 ...until 9
Then I need it to read the next row and repeat etc
4567.3.45
4567.3.46
Hope this makes sense :)
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,571
Office Version
2010
Platform
Windows
Give the following macro a try (data assumed to be in Columns A:D starting on Row 2, output starting at cell F1)...
Code:
Sub MakeBranchSubDeptSeries()
  Dim R As Long, OutR As Long, X As Long, LastRow As Long, OutputRowCount As Long
  Dim BranchSubDept As String, Data As Variant, Result As Variant
  LastRow = Cells(Rows.Count, "A").End(xlUp).Row
  Data = Range("A2:D" & LastRow)
  OutputRowCount = Application.Sum(Evaluate("D2:D" & LastRow & "-C2:C" & LastRow & "+1"))
  ReDim Result(1 To OutputRowCount, 1 To 1)
  For R = 1 To UBound(Data)
    BranchSubDept = Data(R, 1) & "." & Data(R, 2) & "."
    For X = Data(R, 3) To Data(R, 4)
      OutR = OutR + 1
      Result(OutR, 1) = BranchSubDept & X
    Next
  Next
  Range("F1").Resize(UBound(Result)) = Result
End Sub
HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (MakeBranchSubDeptSeries) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enabl
 

Forum statistics

Threads
1,085,693
Messages
5,385,220
Members
401,936
Latest member
stephenpoff

Some videos you may like

This Week's Hot Topics

Top