我已使用this黑客截取單元格上的鼠標移動。 在A1我已經估算公式如下:Excel中的公用函數無法正常工作,因爲UDF
=IFERROR(HYPERLINK(OnMouseOver(ROW(),COLUMN()),"Click here"), "Click here")
然後我寫了下面的函數來清除在一個大範圍內的所有邊界並繪製鼠標懸停在細胞周圍粗邊框。
Public Function OnMouseOver(row, col)
Dim ra As Range
Set ra = Sheets("Sheet1").Columns("A:BJ") 'Range("griglia")
ra.Borders(xlDiagonalDown).LineStyle = xlNone
ra.Borders(xlDiagonalUp).LineStyle = xlNone
ra.Borders(xlEdgeLeft).LineStyle = xlNone
ra.Borders(xlEdgeTop).LineStyle = xlNone
ra.Borders(xlEdgeBottom).LineStyle = xlNone
ra.Borders(xlEdgeRight).LineStyle = xlNone
ra.Borders(xlInsideVertical).LineStyle = xlNone
ra.Borders(xlInsideHorizontal).LineStyle = xlNone
Set ra = ActiveSheet.Cells(row, col)
ra.Borders(xlDiagonalDown).LineStyle = xlNone
ra.Borders(xlDiagonalUp).LineStyle = xlNone
With ra.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Color = -16776961
.TintAndShade = 0
.Weight = xlThick
End With
With ra.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Color = -16776961
.TintAndShade = 0
.Weight = xlThick
End With
With ra.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Color = -16776961
.TintAndShade = 0
.Weight = xlThick
End With
With ra.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Color = -16776961
.TintAndShade = 0
.Weight = xlThick
End With
End Function
此功能不清除現有邊界,此外它只繪製A1周圍的薄邊框。另一方面,當我運行它通過此代碼時,它的工作原理如下:
Sub testfunction()
Call OnMouseOver(1, 1)
End Sub
爲什麼這種奇怪的行爲?
即使你可以* *改變細胞與UDF格式,你實際上並沒有***返回* **任何東西,所以你對HYPERLINK的第一個參數是'Empty'。 – Comintern
@Comintern - 檢查問題頂部的鏈接 –