+ Reply to Thread
Results 1 to 5 of 5

Record an ever changing cells value from Sheet 1 every 30 seconds into Sheet 2

Hybrid View

stejjfc Record an ever changing cells... 02-19-2013, 07:22 PM
p24leclerc Re: Record an ever changing... 02-19-2013, 09:47 PM
stejjfc Re: Record an ever changing... 02-20-2013, 02:17 PM
p24leclerc Re: Record an ever changing... 02-20-2013, 05:11 PM
stejjfc Re: Record an ever changing... 02-20-2013, 07:03 PM
  1. #1
    Registered User
    Join Date
    09-17-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Record an ever changing cells value from Sheet 1 every 30 seconds into Sheet 2

    Hi

    I have little knowledge of vba and I wonder if someone could help me with my problem please.

    I need to take a record of an ever changing cells value in Sheet 1 every 30 seconds and place it in cell A1 of Sheet 2. Then 30 seconds later record that cells value from Sheet 1 again and this time place it in cell A2 of Sheet 2. Then cell A3 and so on, continuously into a separate cell each time in column A.

    Or another option would be to record the information into cell A1 every time and then push the cells down so that the new record always goes into A1, but this seems harder I think.

    I hope you can understand what I mean and many thanks to anyone who can help.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Record an ever changing cells value from Sheet 1 every 30 seconds into Sheet 2

    Try this macro:
    Public Sub test()
    Dim Start As Variant, asd As Integer
    Start = Timer
    asd = 1
    Do Until Sheets("Sheet1").Range("A1") = "BYE"
      Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = Range("A1")
      Do Until asd = 0
      DoEvents
      asd = Int(Timer - Start) Mod 30
      Loop
      asd = 1
    Loop
    End Sub
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    09-17-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Record an ever changing cells value from Sheet 1 every 30 seconds into Sheet 2

    Thanks for your help Pierre. As I said, my knowledge of vba is very limited.

    Do I just copy & paste this into vba?

    And how do I link column A in Sheet 2 to the cell (say cell C2) in Sheet 1? I have tried a formula to point to the cell but I can't get it to work.

    Thanks again.

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Record an ever changing cells value from Sheet 1 every 30 seconds into Sheet 2

    First of all, I must apologize as there is a problem witht he first macro I published. Here a modified macro that works well:
    Public Sub test()
    Dim Start As Variant, asd As Integer
    Start = Timer
    asd = 1
    Do Until Sheets("Sheet1").Range("A1") = "BYE"
    'This is to be able to stop the macro by entering the word BYE inthe cell A1
      Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = Sheets("Sheet1").Range("A1")
    'Here, it takes the value of cell A1 from Sheet1 (right part of equation)
    'and copy it to the first empty cell in column A of Sheet2.
    'You can change the cell under scope by changing the reference A1 by the cell addrress you want.
    '
    'This loop if there to wait 30 seconds. You can change the 30 to the number you want
      Do Until asd = 0
      asd = Int(Timer - Start) Mod 30
      DoEvents
      Loop
    'This loop is to wait till the end of the 30st second to write the data
    'Otherwise, process is so fast, it would write thousands of duplicates within this second.
      Do Until asd = 1
      asd = Int(Timer - Start) Mod 30
      Loop
    Loop
    End Sub
    I added some comments so you know what a line of program does.
    Look at the attached file for a working workbook.
    Hope this helps
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    09-17-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Record an ever changing cells value from Sheet 1 every 30 seconds into Sheet 2

    That's great Pierre. It's just what I wanted. Thank you so much for your help.

+ 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