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,507
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,082,246
Messages
5,363,995
Members
400,772
Latest member
solbebe

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top