![]() |
Identify the Current Cell
I would like to highlight/shade a certain cell in whichever row I am
currently working on. For example, whenever I am anywhere on row 10 I would like cell A10 to be highlighted or shaded a certain colour, and similarly for row 11 cell A11 etc. I have been looking for a function like ACTIVEROW or ACTIVECELL so that I can then use conditional formatting, but can't find anything. I am using EXCEL 2007. Please help. Thanks. |
Identify the Current Cell
How about this? Be aware, it will destroy any other CF you have
'---------------------------------------------------------------- Private Sub Worksheet_SelectionChange(ByVal Target As Range) '---------------------------------------------------------------- Cells.FormatConditions.Delete With Target With .EntireRow .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE" With .FormatConditions(1) With .Borders(xlTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With With .Borders(xlBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With .Interior.ColorIndex = 20 End With End With With .EntireColumn .FormatConditions.Delete .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE" With .FormatConditions(1) With .Borders(xlLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With With .Borders(xlRight) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With .Interior.ColorIndex = 20 End With End With .FormatConditions.Delete .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = 36 End With End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Staanley" wrote in message ... I would like to highlight/shade a certain cell in whichever row I am currently working on. For example, whenever I am anywhere on row 10 I would like cell A10 to be highlighted or shaded a certain colour, and similarly for row 11 cell A11 etc. I have been looking for a function like ACTIVEROW or ACTIVECELL so that I can then use conditional formatting, but can't find anything. I am using EXCEL 2007. Please help. Thanks. |
Identify the Current Cell
Have a look here
http://www.cpearson.com/excel/RowLiner.htm Mike "Staanley" wrote: I would like to highlight/shade a certain cell in whichever row I am currently working on. For example, whenever I am anywhere on row 10 I would like cell A10 to be highlighted or shaded a certain colour, and similarly for row 11 cell A11 etc. I have been looking for a function like ACTIVEROW or ACTIVECELL so that I can then use conditional formatting, but can't find anything. I am using EXCEL 2007. Please help. Thanks. |
Identify the Current Cell
Bob,
Thanks very much. The problem I have is that the worksheet is quite heavily formatted and I guess this would destroy that. I would say I am a fairly competent EXCEL user, but am not an expert, so I hope I have not misunderstood you. Cheers, Ian. "Bob Phillips" wrote: How about this? Be aware, it will destroy any other CF you have '---------------------------------------------------------------- Private Sub Worksheet_SelectionChange(ByVal Target As Range) '---------------------------------------------------------------- Cells.FormatConditions.Delete With Target With .EntireRow .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE" With .FormatConditions(1) With .Borders(xlTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With With .Borders(xlBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With .Interior.ColorIndex = 20 End With End With With .EntireColumn .FormatConditions.Delete .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE" With .FormatConditions(1) With .Borders(xlLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With With .Borders(xlRight) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With .Interior.ColorIndex = 20 End With End With .FormatConditions.Delete .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = 36 End With End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Staanley" wrote in message ... I would like to highlight/shade a certain cell in whichever row I am currently working on. For example, whenever I am anywhere on row 10 I would like cell A10 to be highlighted or shaded a certain colour, and similarly for row 11 cell A11 etc. I have been looking for a function like ACTIVEROW or ACTIVECELL so that I can then use conditional formatting, but can't find anything. I am using EXCEL 2007. Please help. Thanks. |
Identify the Current Cell
It won't destroy formatting, other than any conditional formatting It does
destroy that I am afraid. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Staanley" wrote in message ... Bob, Thanks very much. The problem I have is that the worksheet is quite heavily formatted and I guess this would destroy that. I would say I am a fairly competent EXCEL user, but am not an expert, so I hope I have not misunderstood you. Cheers, Ian. "Bob Phillips" wrote: How about this? Be aware, it will destroy any other CF you have '---------------------------------------------------------------- Private Sub Worksheet_SelectionChange(ByVal Target As Range) '---------------------------------------------------------------- Cells.FormatConditions.Delete With Target With .EntireRow .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE" With .FormatConditions(1) With .Borders(xlTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With With .Borders(xlBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With .Interior.ColorIndex = 20 End With End With With .EntireColumn .FormatConditions.Delete .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE" With .FormatConditions(1) With .Borders(xlLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With With .Borders(xlRight) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = 5 End With .Interior.ColorIndex = 20 End With End With .FormatConditions.Delete .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE" .FormatConditions(1).Interior.ColorIndex = 36 End With End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Staanley" wrote in message ... I would like to highlight/shade a certain cell in whichever row I am currently working on. For example, whenever I am anywhere on row 10 I would like cell A10 to be highlighted or shaded a certain colour, and similarly for row 11 cell A11 etc. I have been looking for a function like ACTIVEROW or ACTIVECELL so that I can then use conditional formatting, but can't find anything. I am using EXCEL 2007. Please help. Thanks. |
Identify the Current Cell
Mike,
Thanks very much - this is excellent. Cheers, Ian. "Mike H" wrote: Have a look here http://www.cpearson.com/excel/RowLiner.htm Mike "Staanley" wrote: I would like to highlight/shade a certain cell in whichever row I am currently working on. For example, whenever I am anywhere on row 10 I would like cell A10 to be highlighted or shaded a certain colour, and similarly for row 11 cell A11 etc. I have been looking for a function like ACTIVEROW or ACTIVECELL so that I can then use conditional formatting, but can't find anything. I am using EXCEL 2007. Please help. Thanks. |
All times are GMT +1. The time now is 01:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com