What am I doing wrong here?
I am trying to make clickable cell in 1st sheet,that will take value from next cell (offset 0,1) and add that to a VBA code to retrieve data from Yahoo Finance in 2nd sheet ("Hold").
I get an error [Underlined part] 'cause data can only be retrieved to 1st sheet, and that I don't want. Code is in 1st sheet not in module.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column <> 4 Then Exit Sub
Application.EnableEvents = False
Dim strURL1 As String
If Target.Column = 4 Then
WordLoc = ActiveCell.Offset(0, 1)
Range("A1").Select
Worksheets("Hold").Range("A1:e35").ClearContents
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/q/hl?s=" & WordLoc & "+Holdings", Destination:=Range("$A$1" _
))
.Name = "hl?s=" & WordLoc & "+Holdings_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "7,9,11,13"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End If
End If
Application.EnableEvents = True
End Sub
Any help would be appreciated.
Bookmarks