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 :)
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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