Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Refreshing Web Query & Saving

Hi,

I am unfortunatly not very proficient in Excel. I have created a
simple web query that refreshes every minute. However, what I would
like it to do is to save after each refresh is to "time stamp" and go
to the next available line where the next refrehable data would go
until I finally press the break button.

Example.

- 1st data returned starts at cell A1 to F15.
- Then a time stamp in cells G1 to G15.
- Save
- On the next refresh, the next available cell ( A16 ) is used etc
etc.

Any help would be greatly appreciated.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Refreshing Web Query & Saving


Why try to move the web query? Just move the data instead. The example
below uses the 'Worksheet_Change' event of the sheet with the web query to
trigger a copy/paste operation that copies the updated data to the clipboard
and then pastes it at the end of the data on another sheet. The routine also
adds a time stamp in the next available column. You will probably have to
modify it a little to suit your needs. I assumed that the sheet you save the
data on will be named "Saved Data".

Instructions: Right-click on the worksheet tab of the sheet with the web
query. Select "View Code". Copy the code below and paste it into the Visual
Basic Editor window. The code will run every time your web query updates the
data.

HTH,

Eric

Private Sub Worksheet_Change(ByVal Target As Range)
Dim dataRange As Range
Dim wsCurrent As String, wsName As String

wsCurrent = ActiveSheet.Name
Me.Select ' Select the sheet with the change event
wsName = Me.Name ' Save the sheet name

Set dataRange = ActiveWorkbook.Worksheets(wsName).Range("A1:F15")
'
' If the data in our target block changed, do the
' stuff below.
'
If (Not Intersect(Target, dataRange) Is Nothing) Then
Application.ScreenUpdating = False
Application.EnableEvents = False
dataRange.Select
Selection.Copy
ActiveWorkbook.Worksheets("Saved Data").Select
ActiveSheet.Cells(ActiveSheet.Rows.Count,
"A").End(xlUp).Offset(1, 0).Select
Selection = dataRange
ActiveSheet.Paste
ActiveCell.Offset(0, 6).Resize(15, 1).Select
ActiveCell.Value = Now() ' Apply a time stamp to the data
Selection.FillDown
ActiveWorkbook.Worksheets(wsCurrent).Select
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
'
End Sub


"qcan" wrote:

Hi,

I am unfortunatly not very proficient in Excel. I have created a
simple web query that refreshes every minute. However, what I would
like it to do is to save after each refresh is to "time stamp" and go
to the next available line where the next refrehable data would go
until I finally press the break button.

Example.

- 1st data returned starts at cell A1 to F15.
- Then a time stamp in cells G1 to G15.
- Save
- On the next refresh, the next available cell ( A16 ) is used etc
etc.

Any help would be greatly appreciated.

Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Refreshing Web Query & Saving

On Jul 8, 6:03*pm, EricG wrote:
Why try to move thewebquery? *Just move the data instead. *The example
below uses the 'Worksheet_Change' event of the sheet with thewebqueryto
trigger a copy/paste operation that copies the updated data to the clipboard
and then pastes it at the end of the data on another sheet. *The routine also
adds a time stamp in the next available column. *You will probably have to
modify it a little to suit your needs. *I assumed that the sheet you save the
data on will be named "Saved Data".

Instructions: *Right-click on the worksheet tab of the sheet with thewebquery. *Select "View Code". *Copy the code below and paste it into the Visual
Basic Editor window. *The code will run every time yourwebqueryupdates the
data.

HTH,

Eric

Private Sub Worksheet_Change(ByVal Target As Range)
* * Dim dataRange As Range
* * Dim wsCurrent As String, wsName As String

* * wsCurrent = ActiveSheet.Name
* * Me.Select ' Select the sheet with the change event
* * wsName = Me.Name ' Save the sheet name

* * Set dataRange = ActiveWorkbook.Worksheets(wsName).Range("A1:F15")
'
' If the data in our target block changed, do the
' stuff below.
'
* * If (Not Intersect(Target, dataRange) Is Nothing) Then
* * * * Application.ScreenUpdating = False
* * * * * * Application.EnableEvents = False
* * * * * * * * dataRange.Select
* * * * * * * * Selection.Copy
* * * * * * * * ActiveWorkbook.Worksheets("Saved Data").Select
* * * * * * * * ActiveSheet.Cells(ActiveSheet.Rows.Count,
"A").End(xlUp).Offset(1, 0).Select
* * * * * * * * Selection = dataRange
* * * * * * * * ActiveSheet.Paste
* * * * * * * * ActiveCell.Offset(0, 6).Resize(15, 1).Select
* * * * * * * * ActiveCell.Value = Now() *' Apply a time stamp to the data
* * * * * * * * Selection.FillDown
* * * * * * * * ActiveWorkbook.Worksheets(wsCurrent).Select
* * * * * * Application.EnableEvents = True
* * * * Application.ScreenUpdating = True
* * End If
'
End Sub



"qcan" wrote:
Hi,


I am unfortunatly not very proficient in Excel. I have created a
simplewebquerythat refreshes every minute. However, what I would
like it to do is to save after each refresh is to "time stamp" and go
to the next available line where the next refrehable data would go
until I finally press the break button.


Example.


- 1st data returned starts at cell A1 to F15.
- Then a time stamp in cells G1 to G15.
- Save
- On the next refresh, the next available cell ( A16 ) is used etc
etc.


Any help would be greatly appreciated.


Thanks.- Hide quoted text -


- Show quoted text -


Thanks very much Eric. It works flawlessly !!!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving/Refreshing with Ontime JB Excel Programming 0 November 29th 07 07:22 PM
saving and refreshing workbook linked to a SQL database Texas Tonie[_2_] Excel Discussion (Misc queries) 0 November 9th 07 11:03 PM
refreshing web query ezil Excel Programming 2 August 2nd 07 08:16 PM
Help! Query Refreshing Emma Hope Excel Programming 2 September 19th 05 05:28 PM
Parameter Query not refreshing. MER Excel Programming 3 May 26th 05 09:15 PM


All times are GMT +1. The time now is 06:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"