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: 2,836
Default Loop Through Array Copy/Paste Value into VBA Code

Many people that visit this Discussion Group have provided me with help in
the past; I am hoping someone can help me out once more.

I have been battling this problem for quite some time now. I have a long
list of stock symbols (106 total, all in ColumnD). I am wondering if there
is a way to loop through the entire array and copy/paste each value into a
certain section of a VBA macro that I recorded to get daily stock prices from
the Yahoo finance web site.

Again, am trying to get the code to start in Cell D2 (for instance)
recognize that the value is KFT (for Kraft Foods Inc.), copy/paste this value
into the snippet of code into the "KFT" spot below:
"URL;http://finance.yahoo.com/q/hp?s=KFT&a=00&b=1&c=2007&d=02&e=14&f=2007&g=d" _


Below is my full macro:
Sub HistoricalData()

'KFT - Historical Data
Sheets("KFT").Select
Cells.Select
Range("A1:IJ50000").ClearContents


With ActiveSheet.QueryTables.Add(Connection:= _

"URL;http://finance.yahoo.com/q/hp?s=KFT&a=00&b=1&c=2007&d=02&e=14&f=2007&g=d" _
, Destination:=Range("A1"))
.Name = "hp?s=KFT&a=00&b=1&c=2007&d=02&e=14&f=2007&g=d "
.FieldNames = True
.RowNumbers = False
.WebTables = "20"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Columns("A:A").ColumnWidth = 11.14

Cells.Select
With Selection
.MergeCells = False
End With


Range("A1").Select
Range("B:D,F:G").Select
Range("F1").Activate
Selection.Delete shift:=xlToLeft
Range("A1").Select

End Sub


Ive seen Excel do some pretty AMAZING things over the years. Not sure if
Excel can handle this task or not, but it would be awesome if it could!!

Regards
RyGuy---

 
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
copy paste loop---new to vba MFR Excel Programming 4 October 26th 06 08:25 PM
Copy and Paste using a loop bestie via OfficeKB.com Excel Programming 0 August 3rd 06 08:57 AM
Creating Loop to Paste Array Nate Excel Programming 1 January 5th 06 03:59 AM
Copy/Paste Loop Jelly''s Excel Programming 0 December 6th 05 10:10 PM
Excel VBA, Loop, array, cut and paste [email protected] Excel Programming 1 September 23rd 05 06:40 PM


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

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"