PC Review


Reply
Thread Tools Rate Thread

Activate Condition When Another Cell Is Selected

 
 
T Tran
Guest
Posts: n/a
 
      24th Jun 2008
Is it possible to have conditions on cells that activate upon another cell
being selected?

For example:
Column A contains dates;
Row 1 contains personnel names;
Data reflects personnel's attendance;

If a date is selected, is it possible to have the cells (of the personnel
who are present) highlighted and bold based on whether or not they are
present?
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      24th Jun 2008
Assuming the grid where the people are marks as present ia named range
called data, and you mark them with an x

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cell As Range

If Target.Column = 1 Then

Me.Range("data").Cells.Interior.ColorIndex = xlColorIndexNone
For Each cell In Me.Range("data").Rows(Target.Row -
Me.Range("data").Cells(1, 1).Row + 1).Cells

If cell.Value = "x" Then

cell.Interior.ColorIndex = 38
End If
Next cell
End If
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"T Tran" <(E-Mail Removed)> wrote in message
news:E0FC3C3F-493A-4EEE-955E-(E-Mail Removed)...
> Is it possible to have conditions on cells that activate upon another cell
> being selected?
>
> For example:
> Column A contains dates;
> Row 1 contains personnel names;
> Data reflects personnel's attendance;
>
> If a date is selected, is it possible to have the cells (of the personnel
> who are present) highlighted and bold based on whether or not they are
> present?



 
Reply With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      24th Jun 2008
Hi
Put this in the codemodule for your sheet (double click sheet name in
VB Editor). I'm assuming dates are in the left most column, names are
on the top row and the data area has a 1 in the cell if a persaon is
in on that date.
Select the whole table, including columns, and give it the name MyData
(Insert, Names, Define..click Add button)
Cell will be coloured red and 1 put in bold when a date is clicked.
Click off the dates to remove the effect.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Integer
If Not Intersect(Target, Range("MyData").Columns(1)) Is Nothing Then
If Target.Count = 1 Then
For i = 1 To Range("MyData").Columns.Count - 1
With Target.Offset(0, i)
If .Value = 1 Then
.Font.Bold = True
.Interior.ColorIndex = 3
End If
End With
Next i
End If
Else
With Range("MyData")
.Font.Bold = False
.Interior.ColorIndex = 0
End With
End If

End Sub

regards
Paul

On Jun 24, 2:20*pm, T Tran <TT...@discussions.microsoft.com> wrote:
> Is it possible to have conditions on cells that activate upon another cell
> being selected?
>
> For example:
> Column A contains dates;
> Row 1 contains personnel names;
> Data reflects personnel's attendance;
>
> If a date is selected, is it possible to have the cells (of the personnel
> who are present) highlighted and bold based on whether or not they are
> present?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save selected items NOT selected in an Extended List Box based onother condition big.brown Microsoft Access Form Coding 6 8th Oct 2009 06:57 PM
How do I activate the next cell in a selected range? =?Utf-8?B?UnViYmxl?= Microsoft Excel Programming 8 23rd Aug 2007 12:22 AM
Activate last cell in selected range - an example DataFreakFromUtah Microsoft Excel Programming 11 5th Sep 2004 02:02 AM
Changing cell colour when cell selected/de-selected by mouse/arrow keys Joe Hannett Microsoft Excel Misc 5 12th Aug 2004 05:39 PM
Activate user form upon condition fishergomz Microsoft Excel Programming 2 6th May 2004 03:36 PM


Features
 

Advertising
 

Newsgroups
 


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