本帖最后由 lexianfeng 于 2024-12-23 08:36 编辑
在vba中定义一个高亮显示选中单元格行列的方法,怎么可以实现在其他表中直接调用,请高手帮忙
Public Sub HighlightCurrentRowAndColumn(ByVal e As SpreadsheetGear.Windows.Controls.RangeSelectionChangedEventArgs)
Dim currentRow As Long, currentCol As Long
Dim colorIndex As Long
' 获取当前选中单元格的行号和列号
currentRow = e.RangeSelection.Row
currentCol = e.RangeSelection.Column
' 定义要使用的颜色索引(可以根据需要修改)
colorIndex = 16 ' 例如,使用黄色(索引6)
' 清除之前的高亮(如果有的话)
With AW.ActiveWorksheet.UsedRange.Interior
.Pattern = SpreadsheetGear.Pattern.None
End With
' 高亮显示当前行和列
With e.RangeSelection.EntireRow.Interior
.ColorIndex = colorIndex
End With
With e.RangeSelection.EntireColumn.Interior
.ColorIndex = colorIndex
End With
End Sub
' 在其他地方调用Call HighlightCurrentRowAndColumn(e)
|
|
lexianfeng