+ Reply to Thread
Results 1 to 3 of 3

imbricated loops problem

Hybrid View

  1. #1
    Registered User
    Join Date
    12-10-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    imbricated loops problem

    Hi,

    I need your help for this problem:

    my data looks like this:

    xxx 3
    yyy 2
    zzz 1
    ...

    and I need it like this :

    xxx
    xxx
    xxx
    yyy
    yyy
    zzz
    ...

    Thank you for your help
    Last edited by nicer2011; 12-12-2011 at 04:35 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: imbricated loops problem

    Try this, it assumes the data starts in A1.
    Sub ExpandData()
    Dim rng As Range
    Dim NoRows As Long
    
            Set rng = Range("A1")
     
            While rng.Value <> ""
                    NoRows = rng.Offset(, 1).Value
                    If NoRows > 1 Then
                    rng.Offset(1).Resize(NoRows - 1).EntireRow.Insert
                    rng.Resize(NoRows).Value = rng.Value
                    End If
                    Set rng = rng.Offset(NoRows)
            Wend
    End Sub

  3. #3
    Registered User
    Join Date
    12-10-2011
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: imbricated loops problem

    Thank you Norie for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1