[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

excel 2013

Posted on 2016-10-12
1
Medium Priority
?
59 Views
Last Modified: 2016-10-14
I have two columns in excel, one for unique I'd and second total data,  in below example I would like to explain
I'D.   total data
12.     5
14.      60
18.     44

I would like to create 5 rows for I'd 12 with starting from 01.01.2016, 60 rows for I'd 14 with starting date from 01.01.2016, it should look like below
I'd.   date
12.    01.01.2016
12.    01.02.2016
12.    01.03.2016
12.    01.04.2016
12.   01.05.2016

how I can do that, I have many records that I want to create dates for that
0
Comment
Question by:snhandle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
Norie earned 2000 total points
ID: 41841170
If the original data was in columns A and B on the active sheet and started in row 2 this code will put the 'expanded' data in columns D and E.
Sub ExpandData()
Dim arrIn As Variant
Dim arrOut As Variant
Dim I As Long
Dim J As Long
Dim cnt As Long

    arrIn = Range("A2", Range("B" & Rows.Count).End(xlUp)).Value
    
    ReDim arrOut(1 To Application.Sum(Application.Index(arrIn, , 2)), 1 To 2)
    
    cnt = 1
    
    For I = LBound(arrIn) To UBound(arrIn)
        For J = 1 To arrIn(I, 2)
            arrOut(cnt, 1) = arrIn(I, 1)
            arrOut(cnt, 2) = DateSerial(2016, 1, 1) + J - 1
            cnt = cnt + 1
        Next J
    Next I
    
    Range("D1:E1").Value = Array("ID", "Date")
    
    With Range("D2").Resize(UBound(arrOut, 1), UBound(arrOut, 2))
        .Value = arrOut
        .EntireColumn.AutoFit
    End With
    
End Sub

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question