Closed Thread
Results 1 to 6 of 6

Creating a Loop for this procedure

  1. #1
    Registered User
    Join Date
    11-04-2010
    Location
    Kingston, Ontario
    MS-Off Ver
    Excel 2007
    Posts
    6

    Exclamation Creating a Loop for this procedure

    I need to create a loop that will use this code again but for the row below it. I am trying to create a timetable from a table and the code I have works for the first row, but I need it to do the same thing for the 3 rows below it . I have attached a word document that shows what the table needs to look like after the procedure is run.

    Sub Timetable()

    st = Range("B2")
    meeting = Range("A2")
    et = Range("C2")
    Location = Range("D2")
    diff = et - st - 1
    Range(Cells(st, 2), Cells(st + diff, 3)).Interior.ColorIndex = 5
    Cells(st, 2) = meeting
    Cells(st, 3) = Location


    End Sub
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Creating a Loop for this procedure

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Creating a Loop for this procedure

    For gods sake use outlook :P.

    Otherwise this should work
    Please Login or Register  to view this content.
    Note in your example it goes to row 5. Code will need to be changed if you have more meetings.

  4. #4
    Registered User
    Join Date
    11-04-2010
    Location
    Kingston, Ontario
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Creating a Loop for this procedure

    Hey thanks a lot for that, is there anyway I can set the colors instead of having them randomly generated? I would like to keep it consistent

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Creating a Loop for this procedure

    Hmmm. This line of code sets the interior color.

    Please Login or Register  to view this content.
    If you just set it to a static value all the ranges will be the same interior color. We could probably do something to where it picks a random color but excludes specific colors. In terms of uniformity I can't think of an easy way to set the code to do specific colors in a specific order. ( You might just need to do it manually). Someone else on here with more experience might know an easy way.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Creating a Loop for this procedure

    Your thread is being closed for non compliance with our rules. Please PM me when you have read the forum rules RULES and made the changes to your post accordingly, i will then unlock your post so you may continue with the thread!

    Post Closed
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

Closed Thread

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