Results 1 to 4 of 4

Excel 2007 : How to create a loop with this code?

Threaded View

  1. #1
    Registered User
    Join Date
    08-08-2008
    Location
    Johannesburg
    MS-Off Ver
    2007
    Posts
    55

    How to create a loop with this code?

    Hi All
    I'm using this code to populate a list of 'names'
    in to a new range where each 'name'/(cell) have 22 cells space between each other:
    Sub PopulateNames()
    
    Worksheets("January").Range("W1").Formula = "=$A9"
    Worksheets("January").Range("W23").Formula = "=$A10"
    Worksheets("January").Range("W45").Formula = "=$A11"
    Worksheets("January").Range("W67").Formula = "=$A12"
    Worksheets("January").Range("W89").Formula = "=$A13"
    Worksheets("January").Range("W111").Formula = "=$A14"
    Worksheets("January").Range("W133").Formula = "=$A15"
    Worksheets("January").Range("W155").Formula = "=$A16"
    Worksheets("January").Range("W177").Formula = "=$A17"
    
    End Sub
    This is a very long list (avg' of 100 'names')
    So I need to loop this action to have a better macro code
    Also the macro must use the cell "A7" to get the number of loops.
    (So if "A7" contains 76, the macro will loop for 76 times)

    Any suggestions to how should I go with this?

    Many thanks for your help,

    Amit
    Last edited by furiousfox; 05-23-2010 at 07:52 AM.
    Using Excel 2007.
    Amit Cohen

Thread Information

Users Browsing this Thread

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

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