+ Reply to Thread
Results 1 to 11 of 11

Creating a list from a new list utilizing VBA

Hybrid View

rubbery Creating a list from a new... 08-09-2013, 10:36 AM
Solus Rankin Re: Creating a list from a... 08-09-2013, 10:42 AM
Norie Re: Creating a list from a... 08-09-2013, 10:43 AM
rubbery Re: Creating a list from a... 08-09-2013, 10:48 AM
rubbery Re: Creating a list from a... 08-09-2013, 10:50 AM
Norie Re: Creating a list from a... 08-09-2013, 10:58 AM
rubbery Re: Creating a list from a... 08-09-2013, 11:03 AM
Solus Rankin Re: Creating a list from a... 08-09-2013, 11:09 AM
Norie Re: Creating a list from a... 08-09-2013, 11:10 AM
rubbery Re: Creating a list from a... 08-09-2013, 11:13 AM
Solus Rankin Re: Creating a list from a... 08-09-2013, 11:48 AM
  1. #1
    Registered User
    Join Date
    06-17-2013
    Location
    Liphook
    MS-Off Ver
    Excel 2010
    Posts
    5

    Creating a list from a new list utilizing VBA

    Hi there,

    I'm certain I'm going to explain this badly, but here goes.

    I have a list on one sheet, and I want to use that as a base to create another list.

    So I've got...

    A1: Listitem1
    A2: Listitem2
    A3: Listitem3

    and I'd like...

    A1: Listitem1 Required
    A2: Listitem1 Actual
    A3: Listitem2 Required
    A4: Listitem2 Actual
    A5: Listitem3 Required
    A6: Listitem3 Actual

    and I'd like it to iterate through as long as there are items in the original list.

    Can anyone out there a little bit smarter than me help?

    Thanks

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Creating a list from a new list utilizing VBA

    Welcome to the forum! Any chance you could attach an example workbook with a before and after example?

    To attach a workbook: Click the 'Go Advanced' button below, then use the paperclip button in the toolbar.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

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

    Re: Creating a list from a new list utilizing VBA

    Try this.
    Option Explicit
    Sub NewList()
    Dim rng As Range
    
        Set rng = Range("A1")
    
        Do Until rng.Value = ""
            With rng.Offset(1)
                .Insert xlShiftDown
                .Offset(-1).Value = rng.Value
                .Offset(-2, 1).Value = "Required"
                .Offset(-1, 1).Value = "Actual"
            End With
            Set rng = rng.Offset(2)
        Loop
        
    End Sub
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    06-17-2013
    Location
    Liphook
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Creating a list from a new list utilizing VBA

    Thanks both for the quick replies.

    Norie, that worked beautifully, thanks! What would I need to add/change in order for the new list to be created on a separate sheet, named "dynamic list"?

    Cheers,
    Pete

  5. #5
    Registered User
    Join Date
    06-17-2013
    Location
    Liphook
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Creating a list from a new list utilizing VBA

    Also, I need them to be in the same cell, not split into two...

    Thanks!

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

    Re: Creating a list from a new list utilizing VBA

    The code would be completely different if you wanted to create the new list on another worksheet.

    As for the same cell, what exactly would you want in the same cell?

  7. #7
    Registered User
    Join Date
    06-17-2013
    Location
    Liphook
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Creating a list from a new list utilizing VBA

    I'll try to explain a little better...

    I want the original list item repeated twice, with "required" or "actual" affixed to the end.

    In a formula (which i'm far better with!) it would be either =CONCATENATE(A1," Required") or =A1& " Required"

    Unfortunately I really need it on another sheet, I have to keep the original list in tact...

    Thanks so much for the help! I've been struggling with this for days...

  8. #8
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Creating a list from a new list utilizing VBA

    Sub NewList()
    Dim l As Long
    Dim lRow As Long
    
    lRow = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
    
    For l = 2 To lRow
        Sheets("dynamic list").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = Sheets("original list").Range("A" & l).Value & " Required"
        Sheets("dynamic list").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = Sheets("original list").Range("A" & l).Value & " Actual"
    Next l
        
    End Sub
    You'll have to change the sheet name "original list" to whatever the sheet name you have.
    Last edited by Solus Rankin; 08-09-2013 at 11:12 AM.

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

    Re: Creating a list from a new list utilizing VBA

    Perhaps.
    Option Explicit
    
    Sub NewListNewSheet()
    Dim rngSrc As Range
    Dim rngDst As Range
    
        Set rngSrc = Worksheets("Sheet1").Range("A1")
        Set rngDst = Worksheets("Sheet2").Range("A1")
        
        Do Until rngSrc.Value = ""
        
            rngDst.Resize(2).Value = Application.Transpose(Array(rngSrc.Value & " Required", rngSrc.Value & " Actual"))
            Set rngDst = rngDst.Offset(2)
            Set rngSrc = rngSrc.Offset(1)
            
        Loop
    End Sub

  10. #10
    Registered User
    Join Date
    06-17-2013
    Location
    Liphook
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Creating a list from a new list utilizing VBA

    Both those solutions work perfectly, thanks so much!

  11. #11
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Creating a list from a new list utilizing VBA

    Glad to help. If you would, please mark the thread as [SOLVED] using the thread tools at the top.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 08-05-2013, 10:08 PM
  2. Replies: 7
    Last Post: 06-12-2013, 07:09 PM
  3. [SOLVED] Taking a list of tasks and a list of subtasks and creating a new list with groupings
    By kknb0800 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-06-2012, 12:16 PM
  4. [SOLVED] Creating a grocery list in a new worksheet based on selected items in a master list
    By jacolli4 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-28-2012, 07:53 AM
  5. How to copy data validation utilizing a list to the entire column
    By Sonjab in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-08-2005, 10:05 AM

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