+ Reply to Thread
Results 1 to 14 of 14

Only repeat once

  1. #1
    Registered User
    Join Date
    02-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    70

    Only repeat once

    Hi this might be one of the old tricks in the book but also this is a simple one i believe, ok here is what i am trying to do
    in the below code i want to take note of time that happens each time (pls see attached file)

    Please Login or Register  to view this content.
    but the problem is that i can't progress on to the next row because the loop goes back to X=1
    again and again, how to overcome this?
    Attached Files Attached Files
    Last edited by jackandjill; 06-24-2010 at 12:11 AM.

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

    Re: Only repeat once

    What are you trying to do? I can't see why you need the loop
    Hope that helps.

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

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    02-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: Only repeat once

    Oops! sorry not being clear the first time. Well basically I want to log the time when ever there is a change in a particular cell that means lets say the first change occurs at 1100hrs then system time should be placed in k1 and the next change occurs at 1115 (can happen anytime not fixed) then the system time will be placed in K2 and so on any easy way to do this...

    For more clarity please see the attached excel file the VBA code i hope i have done somewhat close to my goal

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

    Re: Only repeat once

    There is no attachment

  5. #5
    Registered User
    Join Date
    02-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: Only repeat once

    Strange, sorry about that, but here it is
    also a rapidshare link
    http://rapidshare.com/files/39851633...ging.xlsm.html
    Attached Files Attached Files
    Last edited by jackandjill; 06-13-2010 at 07:06 AM.

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Only repeat once

    Try this

    Please Login or Register  to view this content.

    Because you are triggering the change event with each step in your for loop X will always return to 1

    Disabling .EnableEvents at the begining of your code and resetting at the end, should fix your problem

    Hope this helps.

    If you need any further information, please feel free to ask further

    However

    If this takes care of your needs, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody!
    Also
    If you are satisfied by any members response to your problem please consider using the scales icon top right of thier post to show your appreciation.

  7. #7
    Registered User
    Join Date
    02-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: Only repeat once

    Ok this is somewhat helpful, but please note that i want the word ok to be placed in k1 for the first change, then j5 wont be equal to d4 hence there should be only one OK in k1....after some more process there is a change and J5=D4 again another OK in K2
    The above soultion does is gives me 10 OK at one go which is not what i was expecting,tks for the help

  8. #8
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Only repeat once

    you can add some thing like
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  9. #9
    Registered User
    Join Date
    02-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: Only repeat once

    OK great yes this is what i was looking for with a little glitch, it is why is that the first time that it happens twice? which mean the first time the statement is true the value is being reflected in L1 and L2 for the first time the statement is true.

    Another thing is it is going thru rows i mean it is L1 L2 L3...so on
    But what if i want it to be L1,M1,N1...so on the below code is something i tried but not working please help

    Please Login or Register  to view this content.

  10. #10
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Only repeat once

    The code is your code and does what you asked it to do!

    I don't understand what you are trying to do
    ....after some more process there is a change
    What process?

    Also note that your sheet has a formula in J5 this will not trigger the change event

    It looks like it's H5 that changes
    Change this line
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

    Happy to help, but please try to give a clearer explanation of your problem.

  11. #11
    Registered User
    Join Date
    02-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: Only repeat once

    Ok basically i have a value in d4 which is lets say 15 and i want to change the color of the d4 cell when ever the value in j5 matches to d4..
    J5 is dynmic so the value 15 might go to 16,17,18,16 and then back to 15 again hence trigerring the sub again in this case i want to take note of the time time that this happens so the first time is at 1115 hrs second time might be at 1134 hrs and i would like these values to be displayed in a horizontal like m1,n1,o1 and so on...
    This is what i would like to achieve as simple as posible is better tks
    Last edited by jackandjill; 06-14-2010 at 03:29 AM.

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Only repeat once

    Please Login or Register  to view this content.

  13. #13
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Only repeat once

    Hmm......

    snb
    Your code will not trigger because there is a formula in J5

    jackandjill

    Try this workbook and see if it is close to what you want.

    1/. Enter any value in H5

    2/. Then enter a value that has a match in column L

    3/. Repeat with values at will, then one from column L, etc.........



    Hope this helps.

    If you need any further information, please feel free to ask further

    However

    If this takes care of your needs, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody!
    Also
    If you are satisfied by any members response to your problem please consider using the scales icon top right of thier post to show your appreciation.
    Attached Files Attached Files
    Last edited by Marcol; 06-14-2010 at 08:48 AM. Reason: Note to snb added

  14. #14
    Registered User
    Join Date
    02-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: Only repeat once

    I am sorry for not keeping this post as solved but yes the last solution is very helpful and wroking as expected...thanks

+ 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