+ Reply to Thread
Results 1 to 14 of 14

Thread: Record value of a cell to another cell including the time

  1. #1
    Registered User
    Join Date
    06-30-2011
    Location
    Amsterdam
    MS-Off Ver
    Excel 2007
    Posts
    9

    Record value of a cell to another cell including the time

    Hi,

    I have an Excel sheet where you directly see the quotes of the NYSE. I have made a formula to create a Z-value which tell me to (in my opinion) buy or sell.

    The Z-value is changing every second, because the quotes of the stock market are changing every second. Now I want to record the given Z-values for example every minute or every 5 minutes.

    Unfortunately it is not possible for me to build a macro who automatically record the give Z-values including a specific date and time.

    For example, it has to look like this:
    Day Time Value
    30-6 10:01 0.4687
    30-6 10:02 0.4568
    30-6 10:03 0.4396
    30-6 10:04 0.4402
    30-6 10:05 0.4508
    30-6 10:06 0.4893
    30-6 10:07 0.5013


    Do you have any idea how to create this?

    Best Regards,

    Evert van der Hoorn

  2. #2
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Record value of a cell to another cell including the time

    If the Z-value will be shown in a certain cell , e.g. in cell K12, you can make a macro using application.ontime to copy that value in a certain column/sheet.
    Post an example of your workbook so we can see where the z-value is; and please indicate where you want the different values of z to be stored.



  3. #3
    Registered User
    Join Date
    06-30-2011
    Location
    Amsterdam
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Record value of a cell to another cell including the time

    Here you find a view of the file.

    The green colored Cell BQ44 is the Z-value that changes every second.

    Can you do something with this?

    Thanks in advance!
    Attached Images Attached Images

  4. #4
    Registered User
    Join Date
    06-30-2011
    Location
    Amsterdam
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Record value of a cell to another cell including the time

    Here is e better picture
    Attached Images Attached Images

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

    Re: Record value of a cell to another cell including the time

    You could use this macro:
    Values will be written into column BS

    Sub start1()        '       in werkblad
      Application.StatusBar = DateAdd("N", 1, Now)
      Application.OnTime CDate(Application.StatusBar), "Blad1.start1"
      Cells(Rows.Count, "BS").End(xlUp)(2) = Format(Now, "dd-mmyyyy hh:mm:ss  ") & range("BQ44")
    End Sub
    Put this macro into the macromodule of the sheet that contains the cell BQ44.
    Adapt "Blad1' to the codename of the sheet.
    Last edited by snb; 06-30-2011 at 07:03 AM.



  6. #6
    Registered User
    Join Date
    06-30-2011
    Location
    Amsterdam
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Record value of a cell to another cell including the time

    Thanks! It is working!

    Is there also a possibility that the macro continouisly record the data from cell BQ44 for example every minute?

  7. #7
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Record value of a cell to another cell including the time

    The code I suggested does exactly do that.



  8. #8
    Registered User
    Join Date
    06-30-2011
    Location
    Amsterdam
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Record value of a cell to another cell including the time

    Ok I always got the message after 1 minute that he can't execute Blad1.start1 even if i make a test version.
    You can see it in the picture.

    I used in this piocture the following macro:



    Sub start1() ' in werkblad
    Application.StatusBar = DateAdd("N", 1, Now)
    Application.OnTime CDate(Application.StatusBar), "Blad1.start1"
    Cells(Rows.Count, "E").End(xlUp)(2) = Format(Now, "dd-mmyyyy hh:mm:ss ") & Range("D5")
    End Sub
    Attached Images Attached Images

  9. #9
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Record value of a cell to another cell including the time

    Evert, zet svp even codetags rondom je vba-code.
    I fear you didn't put the macro in the correct place. See the attachment.
    Open the attachment and wait several minutes. See what happens.
    If you want to stop it run macro 'stop1'.
    Attached Files Attached Files
    Last edited by snb; 06-30-2011 at 11:38 AM.



  10. #10
    Registered User
    Join Date
    06-30-2011
    Location
    Amsterdam
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Record value of a cell to another cell including the time

    It's working now! Thanks for that!

    Is it also possible that the output will come in 3 different Columns? For example BS, BT and BU.

  11. #11
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Record value of a cell to another cell including the time

    Please add code tags in your post #8.

    Adapted code:
    Sub start1()        '       in werkblad
      Application.StatusBar = DateAdd("N", 1, Now)
      Application.OnTime CDate(Application.StatusBar), "Blad1.start1"
      Cells(Rows.Count, "BS").End(xlUp)(2).resize(,3) = Format(Now, "dd-mmyyyy hh:mm:ss  ") & range("BQ44")
    End Sub



  12. #12
    Registered User
    Join Date
    06-30-2011
    Location
    Amsterdam
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Record value of a cell to another cell including the time

    Thanks again. Is it also possible to have it like this:
    BS BT and BU.

  13. #13
    Registered User
    Join Date
    06-30-2011
    Location
    Amsterdam
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Record value of a cell to another cell including the time

    Thanks again. Is it also possible to have it like this:
    BS (date) BT (time) and BU (z-value).

    No I have in every cell all the values!

  14. #14
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Record value of a cell to another cell including the time

    You got what you asked for
    Amended code:
    Sub start1()
      Application.StatusBar = DateAdd("N", 1, Now)
      Application.OnTime CDate(Application.StatusBar), "Blad1.start1"
      Cells(Rows.Count, "BS").End(xlUp)(2).resize(,3) = split(Format(Now, "dd-mm-yyyy hh:mm:ss ") & range("BQ44"))
    End Sub



+ 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.2.0