Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
home_server:mswindows_notes [2025-03-18 Tue wk12 16:38] – baumkp | home_server:mswindows_notes [2025-03-18 Tue wk12 17:10] (current) – [MS Excel Highlight Row or Column] baumkp | ||
---|---|---|---|
Line 218: | Line 218: | ||
======MSExcel Tips====== | ======MSExcel Tips====== | ||
+ | |||
+ | =====MS Excel Highlight Row or Column===== | ||
+ | The basic built in way : | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Use conditional formating, but this requires hitting '' | ||
+ | |||
+ | Use a VB macro. | ||
+ | ++++VB Code 1| | ||
+ | < | ||
+ | 'from https:// | ||
+ | Private Sub Worksheet_SelectionChange(ByVal Target As Range) | ||
+ | If Target.Cells.Count > 1 Then Exit Sub | ||
+ | Application.ScreenUpdating = False | ||
+ | |||
+ | 'Clear the color of all cells | ||
+ | Cells.Interior.ColorIndex = 0 | ||
+ | With Target | ||
+ | ' | ||
+ | .EntireRow.Interior.ColorIndex = 38 'or use RGB(200, | ||
+ | .EntireColumn.Interior.ColorIndex = 24 | ||
+ | End With | ||
+ | |||
+ | Application.ScreenUpdating = True | ||
+ | End Sub</ | ||
+ | ++++ | ||
+ | |||
+ | ++++VB Code 2| | ||
+ | < | ||
+ | Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) | ||
+ | Static xRow | ||
+ | Static xColumn | ||
+ | If xColumn <> "" | ||
+ | With Columns(xColumn).Interior | ||
+ | .ColorIndex = xlNone | ||
+ | End With | ||
+ | With Rows(xRow).Interior | ||
+ | .ColorIndex = xlNone | ||
+ | End With | ||
+ | End If | ||
+ | pRow = Selection.row | ||
+ | pColumn = Selection.Column | ||
+ | xRow = pRow | ||
+ | xColumn = pColumn | ||
+ | With Columns(pColumn).Interior | ||
+ | .ColorIndex = 6 | ||
+ | .Pattern = xlSolid | ||
+ | End With | ||
+ | With Rows(pRow).Interior | ||
+ | .ColorIndex = 6 | ||
+ | .Pattern = xlSolid | ||
+ | End With | ||
+ | End Sub</ | ||
+ | ++++ | ||
=====Text to Column===== | =====Text to Column===== |