Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Can I automatically copy data to a new cell

Status
Not open for further replies.

mmckeel

Technical User
Jul 11, 2001
7
US
I am trying to create a trend report for a real-time database. I have linked to the database and brought back the points. Then on the data toolbar I found a way to automatically refresh this data every 60 seconds. Would prefer a quicker update but doesn't seem to be an option. Let's say the data goes into cell C5. I need a way to move it to say cell d1 and then after the next scan move it to D2 then D3 and so on or even a new sheet. This will give me a range of cells to base my graph on without overwriting the data. Not to good with VBA. Any help would surely be appreciated. Thanks
 



Hi,

Create the QueryTable in a separate sheet, WITHOUT column headings. When the QT refreshes, we will copy the new value to the next empty row of your table.

Using the worksheet_Change event (right click the sheet tab for the sheet containing the QT, and select View Code)
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim lRow As Long
    lRow = Sheets("YourTableSheet").[A1].CurrentRegion.Rows.Count + 1
    If Not Intersect(Target, Query_From_YourDatabase) Is Nothing Then
        Query_From_YourDatabase.Copy Sheets("YourTableSheet").Cells(lRow, "A")
    End If
End Sub
Assumptions:

The QueryTable Name is Query_From_YourDatabase (change to suite)
Your table in in sheet YourTableSheet (change to suit)
You table begins in A1



Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top