ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cell color (https://www.excelbanter.com/excel-programming/340405-cell-color.html)

boogie

cell color
 
Please help. Something like,I want A1 highlighted with yellow color
everytime i click anywhere from B1 to IV1. If i move to anywhere on any
cell, i want the corresponding cell on A column be highlighteg. Just like
rowliner but rowliner highlights the cell that is being clicked. thank you.
boogie



Bob Phillips[_6_]

cell color
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("B1:IV1")) Is Nothing Then
Range("A1").Interior.ColorIndex = 6
Else
Range("A1").Interior.ColorIndex = xlColorIndexNone
End If
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 Phillips

"boogie" wrote in message
...
Please help. Something like,I want A1 highlighted with yellow color
everytime i click anywhere from B1 to IV1. If i move to anywhere on any
cell, i want the corresponding cell on A column be highlighteg. Just like
rowliner but rowliner highlights the cell that is being clicked. thank

you.
boogie





Helmut Weber[_2_]

cell color
 
Hi,

as a beginner in Excel-VBA:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("B1:IV1")) Is Nothing Then
Range("A1").Interior.ColorIndex = 6
Else
Range("A1").Interior.ColorIndex = xlColorIndexNone
End If
End Sub

seems to me to work only on row 1.

How about this one:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim r As Long ' row
r = ActiveCell.Row
Cells(r, 1).Interior.ColorIndex = 6
End Sub

Of course, it is no toggle function.
Once a cell is yellow, it stays yellow.

I don't know how to utilize "target".

Helmut Weber


Bob Phillips[_6_]

cell color
 
That is because the OP asked for it to only work on row 1.

--
HTH

Bob Phillips

"Helmut Weber" wrote in message
...
Hi,

as a beginner in Excel-VBA:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("B1:IV1")) Is Nothing Then
Range("A1").Interior.ColorIndex = 6
Else
Range("A1").Interior.ColorIndex = xlColorIndexNone
End If
End Sub

seems to me to work only on row 1.

How about this one:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim r As Long ' row
r = ActiveCell.Row
Cells(r, 1).Interior.ColorIndex = 6
End Sub

Of course, it is no toggle function.
Once a cell is yellow, it stays yellow.

I don't know how to utilize "target".

Helmut Weber




Helmut Weber[_2_]

cell color
 
Hi Bob,

it seems indeed the question is more a problem than the answer.

Something like, I want A1 highlighted with yellow color
everytime i click anywhere from B1 to IV1


If i move to anywhere on any cell,
i want the corresponding cell on A column be highlighted


Helmut Weber




Boogie

cell color
 
Opps, i apologize to you both if my question was very clear. Actually, If i
want to click on any cell from B to IV, the corresponding cell on A should be
highlighted. Let's say C1 is clicked, then A1 is highlighted. Again if G10 is
clicked, then A10 is highlighted but of course the previous hightlighted cell
in column A is go back to white. Something like what Helmut says, "toggle".
thank you for trying to help. God bless.

"Helmut Weber" wrote:

Hi Bob,

it seems indeed the question is more a problem than the answer.

Something like, I want A1 highlighted with yellow color
everytime i click anywhere from B1 to IV1


If i move to anywhere on any cell,
i want the corresponding cell on A column be highlighted


Helmut Weber





Helmut Weber[_2_]

cell color
 
Hi,

how about this one:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Range(Cells(1, 1), Cells(Rows.Count, 1)).Interior.ColorIndex = 0
Cells(ActiveCell.Row, 1).Interior.ColorIndex = 6
End Sub

Which removes all coloring from the first row,
and then colors the first cell in the row
in which you select a cell, in yellow.
Even if it is the first cell in a row, though.


Helmut Weber


Bob Phillips[_6_]

cell color
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If target.column < 1 Then
Range("A" & Target.Row).Interior.ColorIndex = 6
Else
Range("A:A").Interior.ColorIndex = xlColorIndexNone
End If
End Sub

--
HTH

Bob Phillips

"boogie" wrote in message
...
Opps, i apologize to you both if my question was very clear. Actually, If

i
want to click on any cell from B to IV, the corresponding cell on A should

be
highlighted. Let's say C1 is clicked, then A1 is highlighted. Again if G10

is
clicked, then A10 is highlighted but of course the previous hightlighted

cell
in column A is go back to white. Something like what Helmut says,

"toggle".
thank you for trying to help. God bless.

"Helmut Weber" wrote:

Hi Bob,

it seems indeed the question is more a problem than the answer.

Something like, I want A1 highlighted with yellow color
everytime i click anywhere from B1 to IV1


If i move to anywhere on any cell,
i want the corresponding cell on A column be highlighted


Helmut Weber







Norman Jones

cell color
 
Hi Bob.

I suspect that you intended something like:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("A:A").Interior.ColorIndex = xlColorIndexNone

If Target.Column < 1 Then
Range("A" & Target.Row).Interior.ColorIndex = 6
End If
End Sub


---
Regards,
Norman



"Bob Phillips" wrote in message
...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If target.column < 1 Then
Range("A" & Target.Row).Interior.ColorIndex = 6
Else
Range("A:A").Interior.ColorIndex = xlColorIndexNone
End If
End Sub

--
HTH

Bob Phillips

"boogie" wrote in message
...
Opps, i apologize to you both if my question was very clear. Actually, If

i
want to click on any cell from B to IV, the corresponding cell on A
should

be
highlighted. Let's say C1 is clicked, then A1 is highlighted. Again if
G10

is
clicked, then A10 is highlighted but of course the previous hightlighted

cell
in column A is go back to white. Something like what Helmut says,

"toggle".
thank you for trying to help. God bless.

"Helmut Weber" wrote:

Hi Bob,

it seems indeed the question is more a problem than the answer.

Something like, I want A1 highlighted with yellow color
everytime i click anywhere from B1 to IV1

If i move to anywhere on any cell,
i want the corresponding cell on A column be highlighted

Helmut Weber










All times are GMT +1. The time now is 02:06 PM.

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