+ Reply to Thread
Results 1 to 9 of 9

how to avoid repetition in a row

  1. #1
    Registered User
    Join Date
    12-31-2011
    Location
    Sharjah
    MS-Off Ver
    Excel 2011
    Posts
    15

    how to avoid repetition in a row

    My second session macro is not working plzzz help me ((

    thank u so much in advance
    Attached Files Attached Files

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: how to avoid repetition in a row

    Its very simple. Your 2nd session macro had 2 additional lines of code which were not there in the other sessions.

    Just remove the line with "Do" and the "Loop Until". Your code was continuously looping and hence the issue.

    Also, your code can be written in a much better way. You can discontinue using Select & Activate statements.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: how to avoid repetition in a row

    I have edited your code a bit (by removing all the select statements). You can try it out. Also instead of copying the same code 5 times, you could even use a IF loop to choose the respective column to populate / work with and then assign the same macro to all 5 buttons. This is the edited code with the select statements missing.
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    12-31-2011
    Location
    Sharjah
    MS-Off Ver
    Excel 2011
    Posts
    15

    Re: how to avoid repetition in a row

    Hiiiii thank u sooo much for ur replyyy ))) I also have another question...when I finished writting my "loop until" condition my condition was written in two different lines and that cause a debug how can I get rid of my long "loop until" condition ?

    here's for example my 3rd session condition for the loop

    Loop Until (Range("D4") <> Range("C4") And Range("D4") <> Range("B4")) And (Range("D5") <> Range("C5") And Range("D5") <> Range("B5")) And (Range("D6") <> Range("B6")) And (Range("D6") <> Range("C6")) And (Range("D7") <> Range("B7")) And (Range("D7") <> Range("C7")) And (Range("D8") <> Range("B8")) And (Range("D8") <> Range("C8")) And (Range("D9") <> Range("B9")) And (Range("D9") <> Range("C9")) And (Range("D10") <> Range("B10")) And (Range("D10") <> Range("C10")) And (Range("D11") <> Range("B11")) And (Range("D11") <> Range("C11")) And (Range("D12") <> Range("B12")) And (Range("D12") <> Range("C12"))

    and so on till cell range 28

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: how to avoid repetition in a row

    I guess all you are trying to do is ensure that the values in rows B4 to B28 dont match with C4 to C28 and D4 to D28 row-wise right? I saw that session 2 takes a very long time to run bcoz of the condition. Maybe if you explain how you get the values in sheet3 column B, that might help find a shorter way of doing the loop until code.

    Also, you can put this statement -
    Please Login or Register  to view this content.
    at the beginning of each code and
    Please Login or Register  to view this content.
    at the end. This will eradicate the filter which is an eye-sore specially in the case of Session2.

  6. #6
    Registered User
    Join Date
    12-31-2011
    Location
    Sharjah
    MS-Off Ver
    Excel 2011
    Posts
    15

    Re: how to avoid repetition in a row

    Hiii :D
    thank u for ur reply
    in sheet three a create a new column next to the table # column and randomize numbers using the rand() function after that I soft the 2 column in respect of the rand column and copy and paste the randomized sorted table column in the table

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: how to avoid repetition in a row

    How do you get the values in your 2nd column in Sheet 3?

  8. #8
    Registered User
    Join Date
    12-31-2011
    Location
    Sharjah
    MS-Off Ver
    Excel 2011
    Posts
    15

    Re: how to avoid repetition in a row

    same mechanism rand values...sort the second column in respect to the first column

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: how to avoid repetition in a row

    Oh ok. I didnt see any formula in column B so was wondering.

+ Reply to 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