Q
qitrader888
This is the macro code i'm using to import data from YAHOO into excel
The only thing I need is to be able to run the macro everytime I pres
ENTER in any of these 5 boxes (C3, F3, I3, L3, O3) How do I do that?
Thanks and any help is appreciated.
Sub Stock1()
'
' macro1 Macro
' Macro recorded 2/26/2004 by Fongsaiyuk
'
Dim CoSym As String
CoSym = Worksheets("Main").Range("C3").Value
With Sheets("Stock 1").QueryTables(1)
.Connection = _
"URL;http://table.finance.yahoo.com/d?a=10&b=23&c=2003&d=1&e=24&f=2004&g=d&s=
& CoSym
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = True
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
End Sub
Sub Stock2()
'
' macro1 Macro
' Macro recorded 2/26/2004 by Fongsaiyuk
'
Dim CoSym As String
CoSym = Worksheets("Main").Range("F3").Value
With Sheets("Stock 2").QueryTables(1)
.Connection = _
"URL;http://table.finance.yahoo.com/d?a=10&b=23&c=2003&d=1&e=24&f=2004&g=d&s=
& CoSym
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = True
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
End Sub
Sub Stock3()
'
' Stock3 Macro
' Macro recorded 2/26/2004 by Fongsaiyuk
'
Dim CoSym As String
CoSym = Worksheets("Main").Range("I3").Value
With Sheets("Stock 3").QueryTables(1)
.Connection = _
"URL;http://table.finance.yahoo.com/d?a=10&b=23&c=2003&d=1&e=24&f=2004&g=d&s=
& CoSym
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = True
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
End Sub
Sub Stock4()
'
' macro1 Macro
' Macro recorded 2/26/2004 by Fongsaiyuk
'
Dim CoSym As String
CoSym = Worksheets("Main").Range("L3").Value
With Sheets("Stock 4").QueryTables(1)
.Connection = _
"URL;http://table.finance.yahoo.com/d?a=10&b=23&c=2003&d=1&e=24&f=2004&g=d&s=
& CoSym
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = True
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
End Sub
Sub Stock5()
'
' macro1 Macro
' Macro recorded 2/26/2004 by Fongsaiyuk
'
Dim CoSym As String
CoSym = Worksheets("Main").Range("O3").Value
With Sheets("Stock 5").QueryTables(1)
.Connection = _
"URL;http://table.finance.yahoo.com/d?a=10&b=23&c=2003&d=1&e=24&f=2004&g=d&s=
& CoSym
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = True
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
End Su
The only thing I need is to be able to run the macro everytime I pres
ENTER in any of these 5 boxes (C3, F3, I3, L3, O3) How do I do that?
Thanks and any help is appreciated.
Sub Stock1()
'
' macro1 Macro
' Macro recorded 2/26/2004 by Fongsaiyuk
'
Dim CoSym As String
CoSym = Worksheets("Main").Range("C3").Value
With Sheets("Stock 1").QueryTables(1)
.Connection = _
"URL;http://table.finance.yahoo.com/d?a=10&b=23&c=2003&d=1&e=24&f=2004&g=d&s=
& CoSym
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = True
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
End Sub
Sub Stock2()
'
' macro1 Macro
' Macro recorded 2/26/2004 by Fongsaiyuk
'
Dim CoSym As String
CoSym = Worksheets("Main").Range("F3").Value
With Sheets("Stock 2").QueryTables(1)
.Connection = _
"URL;http://table.finance.yahoo.com/d?a=10&b=23&c=2003&d=1&e=24&f=2004&g=d&s=
& CoSym
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = True
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
End Sub
Sub Stock3()
'
' Stock3 Macro
' Macro recorded 2/26/2004 by Fongsaiyuk
'
Dim CoSym As String
CoSym = Worksheets("Main").Range("I3").Value
With Sheets("Stock 3").QueryTables(1)
.Connection = _
"URL;http://table.finance.yahoo.com/d?a=10&b=23&c=2003&d=1&e=24&f=2004&g=d&s=
& CoSym
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = True
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
End Sub
Sub Stock4()
'
' macro1 Macro
' Macro recorded 2/26/2004 by Fongsaiyuk
'
Dim CoSym As String
CoSym = Worksheets("Main").Range("L3").Value
With Sheets("Stock 4").QueryTables(1)
.Connection = _
"URL;http://table.finance.yahoo.com/d?a=10&b=23&c=2003&d=1&e=24&f=2004&g=d&s=
& CoSym
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = True
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
End Sub
Sub Stock5()
'
' macro1 Macro
' Macro recorded 2/26/2004 by Fongsaiyuk
'
Dim CoSym As String
CoSym = Worksheets("Main").Range("O3").Value
With Sheets("Stock 5").QueryTables(1)
.Connection = _
"URL;http://table.finance.yahoo.com/d?a=10&b=23&c=2003&d=1&e=24&f=2004&g=d&s=
& CoSym
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = True
.WebDisableDateRecognition = False
.WebDisableRedirections = True
.Refresh BackgroundQuery:=False
End With
End Su