Results 1 to 2 of 2

Thread: Copying excel rows from live data
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    May 2019
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)

    Question Copying excel rows from live data

    Hello - I am trying to copy real time data in subsequent rows whenever the data gets updated. I am using the following VBA code. This updates irrespective of any change. I only want it to change when the time stamp in cell A2 is updated. Any suggestions on how can I update this code?

    Private Sub Worksheet_Calculate()
    capturerow = 2
    currow = Range("A65536").End(xlUp).Row
    Cells(currow + 1, 1) = Cells(capturerow, 1)
    Cells(currow + 1, 2) = Cells(capturerow, 2)
    End Sub


  2. #2
    Board Regular
    Join Date
    Oct 2007
    Post Thanks / Like
    7 Post(s)
    2 Thread(s)

    Default Re: Copying excel rows from live data

    Welcome to MrExcel forums.

    Try this:
    Private Sub Worksheet_Calculate()
        Static previousTimestamp As Date
        Dim captureRow As Long, curRow As Long
        If Range("A2").Value <> previousTimestamp Then
            previousTimestamp = Range("A2").Value
            captureRow = 2
            curRow = Range("A65536").End(xlUp).Row
            Application.EnableEvents = False
            Cells(curRow + 1, 1) = Cells(captureRow, 1)
            Cells(curRow + 1, 2) = Cells(captureRow, 2)
            Application.EnableEvents = True
        End If
    End Sub
    PS - to get CODE tags for posting code click the # icon in the message editor and paste your code between them:

    [CODE]your code here[/CODE]

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts