ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Highlight Active Cell (https://www.excelbanter.com/excel-discussion-misc-queries/610-highlight-active-cell.html)

Db1712

Highlight Active Cell
 

Is there a way to highlight a cell currently in use if the sheet is
protected. I found this code in my search however it does not work
with a protected sheet. Thanks for any help with this in advance.




1. Use ALT + F11 to open the VB editor
2. Double click 'ThisWorkbook' in the Project Explorer
3. Paste the following:
Dim PrevCellCol As Long, PrevCellRow As Long

4. In the Code, select 'Workbook' - Workbook_SheetSelectionChange
5. Paste the Following:

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)
If PrevCellCol = 0 Then
PrevCellCol = ActiveCell.Column
PrevCellRow = ActiveCell.Row
Else
Cells(PrevCellRow, PrevCellCol).Interior.ColorIndex = xlNone
End If
ActiveCell.Interior.ColorIndex = 22
PrevCellCol = ActiveCell.Column
PrevCellRow = ActiveCell.Row
End Sub


--
Db1712
------------------------------------------------------------------------
Db1712's Profile: http://www.excelforum.com/member.php...o&userid=15912
View this thread: http://www.excelforum.com/showthread...hreadid=320546


Bob Phillips

Unprotect the sheet before setting the colorindex, and re-protect
afterwards.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Db1712" wrote in message
...

Is there a way to highlight a cell currently in use if the sheet is
protected. I found this code in my search however it does not work
with a protected sheet. Thanks for any help with this in advance.




1. Use ALT + F11 to open the VB editor
2. Double click 'ThisWorkbook' in the Project Explorer
3. Paste the following:
Dim PrevCellCol As Long, PrevCellRow As Long

4. In the Code, select 'Workbook' - Workbook_SheetSelectionChange
5. Paste the Following:

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)
If PrevCellCol = 0 Then
PrevCellCol = ActiveCell.Column
PrevCellRow = ActiveCell.Row
Else
Cells(PrevCellRow, PrevCellCol).Interior.ColorIndex = xlNone
End If
ActiveCell.Interior.ColorIndex = 22
PrevCellCol = ActiveCell.Column
PrevCellRow = ActiveCell.Row
End Sub


--
Db1712
------------------------------------------------------------------------
Db1712's Profile:

http://www.excelforum.com/member.php...o&userid=15912
View this thread: http://www.excelforum.com/showthread...hreadid=320546





All times are GMT +1. The time now is 10:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com