LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Making a macro loop

I use the following macro to extract data and it works fine....
----------------
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.hrimes.com/137.dat", Destination:=Range("A1"))
.Name = "137"
.PreserveFormatting = True
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.Refresh BackgroundQuery:=False
End With
-----------------
However I now need to consolidate data from a range of sources so need to
amend these lines.
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.hrimes.com/137.dat", Destination:=Range("A1"))
.Name = "137"

The data sources will be in a list in Sheet2 in col C. At present there are
6 of these but they could increase dramatically.

So what I'm trying to do is to get the macro to use the list in Col C of
Sheet2 to determine the specific filename at www.hrimes.com

and change the Destination from Range("A1") to the next available cell in
Col B of Sheet1 so each range follows on directly from the other.

So, I've changed the macro (please see below) and appear to have made a hash
of it. The first stage of retrieving the data isn't working and therefore I
haven't been able to test the destination code either. I've snipped the
lines that are the same for brevity.

I would be grateful for any help in getting this right as I'm stuck now.

Many thanks

Kewa

--------------------------------
Dim ws As Worksheet
Dim rng As Range

Set ws = Worksheets("Sheet2")
Set rng = ws.Range("C1:C100")

Sheets("Sheet1").Select
On Error Resume Next
For Each cell In rng
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.hrimes.com/" & rng & ".dat",
Destination:=Range("B2:B" & Range("C65536").End(xlUp).Row+1)
.Name = rng
<SNIP

End With

Next
On Error GoTo 0


End Sub

 
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
Making a macro always available simonc Excel Discussion (Misc queries) 1 April 19th 07 09:30 AM
Do until loop with use of another macro in loop The Excelerator Excel Programming 9 February 28th 07 02:28 AM
MACRO, help for making Marija Excel Programming 3 August 10th 06 10:45 AM
Making macros loop McKCollins Excel Programming 2 July 10th 06 01:57 PM
Need Help on Making a Loop japorms[_7_] Excel Programming 2 September 16th 05 01:52 PM


All times are GMT +1. The time now is 12:07 AM.

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

About Us

"It's about Microsoft Excel"