Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro causes "Do you want to replace the contents of the destination cells"

Hello,
I have a macro that retrieves data from Yahoo (Sub quotesColK())
and it works fine. I then run Sub ColKExpK() and this also works
fine. But, when I now run Sub quotesColK() ( after having run Sub
ColKExpK()) I get the message "Do you want to replace the contents of
the destination cells" and if I respond yes, the "Label Rows (rows 1
& 2) shift to the right one cell and the data does not line up
correctly. What changes in the code, to either macro, do I need to
make so that this "shift" does not happen?

Thanks.
JBESr



Sub quotesColK()
Application.ScreenUpdating = False
Sheets("QuoteColKData").Range("$A$3:$P$300").Delet e
Sheets("Quotes").Activate
x = Sheets("Quotes").Range("k" & Rows.Count).End(xlUp).Row
For Each c In Sheets("Quotes").Range(Cells(5, 11), Cells(x, 11))
symbols = symbols & "+" & c
Next

With Sheets("QuoteColKData").QueryTables.Add(Connection :="URL;" _
& "http://finance.yahoo.com/d/quotes.csv?s=" & _
symbols & "&f=snd1t1l1bc1ohgpvd1at8&e=.csv", _
Destination:=Sheets("QuoteColKData").Range("b3"))


.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With

Sheets("QuoteColKData").Select

With Sheets("QuoteColKData")
..[b3:b300].TextToColumns
Destination:=Sheets("QuoteColKData").Range("b3"),
DataType:=xlDelimited, Comma:=True
..Columns("A:X").EntireColumn.AutoFit

End With

Calculate
Application.ScreenUpdating = True
End Sub

Sub ColKExpK()
'
' ColKExpK Macro
' Macro recorded 10/16/2004 by End User
'

Application.ScreenUpdating = False
Sheets("QuoteColKData").Select
Range("Q1:R1").Select
Selection.Copy
Range("Q3:Q108").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Calculate

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro causes "Do you want to replace the contents of the destination cells"

change
Sheets("QuoteColKData").Range("$A$3:$P$300").Delet e
to
Sheets("QuoteColKData").Range("$A$2:$R$300").Delet e

--
Regards,
Tom Ogilvy

"JB" wrote in message
om...
Hello,
I have a macro that retrieves data from Yahoo (Sub quotesColK())
and it works fine. I then run Sub ColKExpK() and this also works
fine. But, when I now run Sub quotesColK() ( after having run Sub
ColKExpK()) I get the message "Do you want to replace the contents of
the destination cells" and if I respond yes, the "Label Rows (rows 1
& 2) shift to the right one cell and the data does not line up
correctly. What changes in the code, to either macro, do I need to
make so that this "shift" does not happen?

Thanks.
JBESr



Sub quotesColK()
Application.ScreenUpdating = False
Sheets("QuoteColKData").Range("$A$3:$P$300").Delet e
Sheets("Quotes").Activate
x = Sheets("Quotes").Range("k" & Rows.Count).End(xlUp).Row
For Each c In Sheets("Quotes").Range(Cells(5, 11), Cells(x, 11))
symbols = symbols & "+" & c
Next

With Sheets("QuoteColKData").QueryTables.Add(Connection :="URL;" _
& "http://finance.yahoo.com/d/quotes.csv?s=" & _
symbols & "&f=snd1t1l1bc1ohgpvd1at8&e=.csv", _
Destination:=Sheets("QuoteColKData").Range("b3"))


.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With

Sheets("QuoteColKData").Select

With Sheets("QuoteColKData")
.[b3:b300].TextToColumns
Destination:=Sheets("QuoteColKData").Range("b3"),
DataType:=xlDelimited, Comma:=True
.Columns("A:X").EntireColumn.AutoFit

End With

Calculate
Application.ScreenUpdating = True
End Sub

Sub ColKExpK()
'
' ColKExpK Macro
' Macro recorded 10/16/2004 by End User
'

Application.ScreenUpdating = False
Sheets("QuoteColKData").Select
Range("Q1:R1").Select
Selection.Copy
Range("Q3:Q108").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Calculate

End Sub



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
"Do you want to replace the contents of the destination cells?" Bob Barnes Excel Discussion (Misc queries) 8 April 2nd 23 08:05 PM
How do I suppress the "Do you want to overwrite the destination cells" message Rojo Habe Setting up and Configuration of Excel 1 July 30th 09 02:24 PM
"Find" a wildcard as a place marker and "replace" with original va Eric Excel Discussion (Misc queries) 1 January 27th 09 06:00 PM
Multiple "source" workbooks linked to single "destination" workboo DAVEJAY Excel Worksheet Functions 1 September 17th 07 05:33 PM
Paste in "match destination format" macro code Hopelesslylost Excel Discussion (Misc queries) 2 June 18th 06 01:58 PM


All times are GMT +1. The time now is 04:34 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"