As the title says.
Adding values first to array and then to worksheet works really fast (15ms for 8000 cells, compared to 350ms when looping on to worksheet). But is there a similar way to add hyperlinks very qickly? Looping direcly on worksheet each cell takes its tool really hard.
I would like to keep same visible value for all cells with custom hyperlinks.
Edit:
With Me.RangeTarget(2, mvaln).Resize(rowi + 1)
Select Case qcolumn.Preprocess
Case 1
For i = 0 To UBound(rsrows, 2)
localcol(i, 0) = Application.WorksheetFunction.Trim(rsrows(j, i))
Next
.Value2 = localcol
Case 2
For i = 0 To UBound(rsrows, 2)
localcol(i, 0) = Application.WorksheetFunction.Degrees(rsrows(j, i))
Next
.Value2 = localcol
Case 3
For i = 0 To UBound(rsrows, 2)
localcol(i, 0) = Application.WorksheetFunction.Radians(rsrows(j, i))
Next
.Value2 = localcol
Case 4
For i = 0 To UBound(rsrows, 2)
If LenB(rsrows(j, i)) > 0 Then
Me.RangeTarget(2 + i, mvaln).Hyperlinks.Add Anchor:=Me.RangeTarget(2 + i, mvaln), Address:=rsrows(j, i), TextToDisplay:="Link"
Else
Me.RangeTarget(2 + i, mvaln).ClearContents
End If
Next
Case 5
... ... ...
This is my current code… at ‘case 4’ I’d like to avoid looping. rsrows(j, i)
is value that needs to be put into sheet. At case 1 to case 3 you can see I put all in temporary array and then on worksheet… but can’t do the same with hyperlinks to speed things up.
I’m not sure what value rsrows(j, i)
contains. Whether it is a URL/File Path or an internal cell reference. Either way, just use the =HYPERLINK()
formula with either .Value2 =
or .Formula =
For i = 0 To UBound(rsrows, 2)
If LenB(rsrows(j, i)) > 0 Then
localcol(i, 0) = "=HYPERLINK(" & rsrows(j, i) & "," & "Link" & ")"
Else
localcol(i, 0) = vbNullString
End If
Next
.Formula = localcol
'.Value2 = localcol
P.S. If you need some help linking to cells within the file take a look this post:
Excel hyperlink to a specific cell
Tags: excelexcel, perl