Hi all,
Is it possible to have a table where I select a cell to type a value in it
and by doing so, another cell is highlighted? For example when I select
quot;April's pricequot; to type a value in it, it automatically highlights quot;March's
pricequot; while I am in that cell. I mean to use it just as a visual aid to type
values that keeping in mind another cell's value is handy.
thankyou!
Ed
No way through formulas or the UI or anything, but you could paste some code
in the Worksheet_SelectionChange() event (right-click on a sheet tab and
select view code...)
The code below colours the cell one to the right of the selected cell in
red. If you need more specific help with the code or implimentation, post
back
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Columns(quot;A:Aquot;)) Is Nothing Then
Columns(quot;B:Bquot;).Interior.ColorIndex = xlNone
Target.Offset(0, 1).Interior.Color = RGB(255, 0, 0)
End If
End Sub
--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HISquot;Edquot; gt; wrote in message
...
gt; Hi all,
gt;
gt; Is it possible to have a table where I select a cell to type a value in it
gt; and by doing so, another cell is highlighted? For example when I select
gt; quot;April's pricequot; to type a value in it, it automatically highlights
gt; quot;March's
gt; pricequot; while I am in that cell. I mean to use it just as a visual aid to
gt; type
gt; values that keeping in mind another cell's value is handy.
gt;
gt; thankyou!
I should add to this
.....one to the right of the selected cell in column A...
--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HISquot;Nick Hodgequot; gt; wrote in message
...
gt; Ed
gt;
gt; No way through formulas or the UI or anything, but you could paste some
gt; code in the Worksheet_SelectionChange() event (right-click on a sheet tab
gt; and select view code...)
gt;
gt; The code below colours the cell one to the right of the selected cell in
gt; red. If you need more specific help with the code or implimentation, post
gt; back
gt;
gt; Private Sub Worksheet_SelectionChange(ByVal Target As Range)
gt; If Not Application.Intersect(Target, Columns(quot;A:Aquot;)) Is Nothing Then
gt; Columns(quot;B:Bquot;).Interior.ColorIndex = xlNone
gt; Target.Offset(0, 1).Interior.Color = RGB(255, 0, 0)
gt; End If
gt; End Sub
gt;
gt; --
gt; HTH
gt; Nick Hodge
gt; Microsoft MVP - Excel
gt; Southampton, England
gt; www.nickhodge.co.uk
gt; HIS
gt;
gt;
gt; quot;Edquot; gt; wrote in message
gt; ...
gt;gt; Hi all,
gt;gt;
gt;gt; Is it possible to have a table where I select a cell to type a value in
gt;gt; it
gt;gt; and by doing so, another cell is highlighted? For example when I select
gt;gt; quot;April's pricequot; to type a value in it, it automatically highlights
gt;gt; quot;March's
gt;gt; pricequot; while I am in that cell. I mean to use it just as a visual aid to
gt;gt; type
gt;gt; values that keeping in mind another cell's value is handy.
gt;gt;
gt;gt; thankyou!
gt;
gt;
Hello Nick, thanks, the code works great, I more or less understand part of
it, enough to choose the column that gives the highlight and the one that is
highlighted... There are somethings that I would like to know if they can be
changed. When I am in the column which gives the highlight to the other, if I
switch to a different column the last cell that was highlighted stays
highlighted. Also if I am in the column which gives the highligt and I select
a range of cells, the highlight goes as well to other cells and stays like
that. Would you know how to make the last cell highlight go away when I leave
the cell?
Does anybody know webpage where I can learn more about codes?
thanks a lot!
Ed
Ed
Does this help?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Columns(quot;A:Aquot;)) Is Nothing Then
Columns(quot;B:Bquot;).Interior.ColorIndex = xlNone
Target.Offset(0, 1).Interior.Color = RGB(255, 0, 0)
Exit Sub
End If
Columns(quot;B:Bquot;).Interior.ColorIndex = xlNone
End Sub
The addition checks to see that the selection is in column A, if it is it
highlights the cell directly to it's right (offset(0,1)), if the selection
isn't in column A then it jumps the if...then...end if statement and runs
the last columns(quot;B:Bquot;) part to clear any colouring from column B
Hope that is what you were looking for?
--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HISquot;Edquot; gt; wrote in message
...
gt; Hello Nick, thanks, the code works great, I more or less understand part
gt; of
gt; it, enough to choose the column that gives the highlight and the one that
gt; is
gt; highlighted... There are somethings that I would like to know if they can
gt; be
gt; changed. When I am in the column which gives the highlight to the other,
gt; if I
gt; switch to a different column the last cell that was highlighted stays
gt; highlighted. Also if I am in the column which gives the highligt and I
gt; select
gt; a range of cells, the highlight goes as well to other cells and stays like
gt; that. Would you know how to make the last cell highlight go away when I
gt; leave
gt; the cell?
gt;
gt; Does anybody know webpage where I can learn more about codes?
gt;
gt; thanks a lot!
gt;
gt; Ed
It's perfect now Nick!
thank you!
Ed
- Dec 18 Mon 2006 20:34
relative highlighting
close
全站熱搜
留言列表
發表留言