PDA

View Full Version : hyperlink



asdzxc
05-15-2012, 01:29 AM
In I1, put formula =HYPERLINK(J:J)
click on J1, I1=a and click on J2, I1=a
but I want: click on J2, I1=b
plse re-write formula

Bob Phillips
05-15-2012, 01:58 AM
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 10 Then

Me.Range("I1").Formula = "=HYPERLINK(" & Target.Address(False, False) & ")"
End If
End Sub

asdzxc
05-15-2012, 02:22 AM
Thank you for the quick response. Plse combine your code and mine.
With ActiveSheet
On Error Resume Next
ThisWorkbook.Connections(1).Delete
Err.Clear: On Error GoTo 0
With Worksheets("Sheet1").QueryTables.Add(Connection:= _
"URL;http://ichart.finance.yahoo.com/table.csv?s=" & _
Worksheets("Sheet1").Range("J1").Value & "&a=11&b=13&c=2011&d=06&e=6&f=2013&g=w&ignore=.xlsx" _
, Destination:=Worksheets("Sheet1").Range("$A$1"))
.Name = _
"MyData"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = 0
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "4"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.Refresh BackgroundQuery:=False
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1)), TrailingMinusNumbers:=True
Range("A1").Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A2:G38")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Columns("E:E").Select
Selection.Copy
Range("B1").Select
ActiveSheet.Paste
Columns("A:B").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Data.xlsx").Activate
Range("A1").Select
ActiveSheet.Paste

Range("C8").Select
ActiveCell.FormulaR1C1 = "=(R[-3]C2)*2-R[-6]C2"
Dim Lt As Long
Lt = Range("b2").End(xlDown).Offset(3, 0).Row
Selection.AutoFill Destination:=Range("c8:c" & Lt), Type:=xlFillDefault
With Range("A" & Rows.Count).End(xlUp)
.AutoFill .Resize(4)


Dim lastrow As Long
Dim selectnum As Long
lastrow = Cells(Rows.Count, "a").End(xlUp).Row
Select Case True
Case lastrow > 30: selectnum = 30
Case lastrow > 20: selectnum = 20
Case lastrow > 10: selectnum = lastrow
End Select
Cells(lastrow - selectnum + 1, "a").Resize(selectnum, 3).Select

Set cht1 = ActiveSheet.Shapes.AddChart
cht1.Chart.ChartType = xlLineMarkers
cht1.Chart.Location xlLocationAsNewSheet
ActiveChart.ChartArea.Select
ActiveChart.PlotArea.Select

Dim ValuesArray(), SeriesValues As Variant
Dim Ctr As Integer, TotCtr As Integer
With ActiveChart
For Each x In .SeriesCollection
SeriesValues = x.Values
ReDim Preserve ValuesArray(1 To TotCtr + UBound(SeriesValues))
For Ctr = 1 To UBound(SeriesValues)
ValuesArray(Ctr + TotCtr) = SeriesValues(Ctr)
Next
TotCtr = TotCtr + UBound(SeriesValues)
Next
.Axes(xlValue).MinimumScaleIsAuto = True
.Axes(xlValue).MaximumScaleIsAuto = True
.Axes(xlValue).MinimumScale = Application.Min(ValuesArray)
.Axes(xlValue).MaximumScale = Application.Max(ValuesArray)
End With
End With
End With
End With
End With
End Sub

Bob Phillips
05-15-2012, 02:35 AM
What is yours doing/supposed to do, and what triggers your code?

asdzxc
05-15-2012, 06:21 AM
What is yours doing/supposed to do, and what triggers your code? click on J1 or J2, produce the same result in my macro:
On Error Resume Next
ThisWorkbook.Connections(1).Delete
Err.Clear: On Error GoTo 0
With Worksheets("Sheet1").QueryTables.Add(Connection:= _
"URL;http://ichart.finance.yahoo.com/table.csv?s=" & _
Worksheets("Sheet1").Range("J:J").Value & "&a=11&b=13&c=2011&d=06&e=6&f=2013&g=w&ignore=.xlsx" _
, Destination:=Worksheets("Sheet1").Range("$A$1"))
.Name = _
"MyData"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = 0
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "4"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.Refresh BackgroundQuery:=False

Aussiebear
05-16-2012, 12:26 AM
That isn't what you were asked! If you don't wish to help us to help you, then find another forum.

A) What does your code do?

B) what triggers your code?