Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88030

change active cell fill color

$
0
0

I have a workbook with some protected sheets.
Users enter data into specific cells of each sheet.
I want the active cell background color to change - for example to red - when it is highlighted and back to the original color when deselected.
I would like to find a macro to assign it to the workbook instead of each worksheet.

I think this code is useful but since I'm a beginner I don't know which parameter should be changed to fit my demand.

Sub ColorCells()
    Dim Data As Range
    Dim cell As Range
    Set currentsheet = ActiveWorkbook.Sheets("Ekandari")
    Set Data = currentsheet.Range("C5:D5,F5:M5,L9")
    For Each cell In Data
        cell.Interior.ColorIndex = 3
    Next
End Sub

Viewing all articles
Browse latest Browse all 88030

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>