PC Review


Reply
Thread Tools Rate Thread

Conditional Formatting - SELECTING COLUMN HEADING IF A CELL IS COLORED

 
 
manan
Guest
Posts: n/a
 
      11th May 2006

Hi

I have a excel worksheet which has conditional formatting. If the
condition is true it changes the background color of the cell to pink.I
want a function so that it searchs a row and if any cell in that row is
coloured pink then it should return the value of column heading at the
end of the row.

e.g

a b c d e
1 20 25 30 40 50
2 TOM MOM SOM KOM JOM
3 MOM TOM KOM JOM SOM

Lets assume b3 and d2 are highlighted in pink because of conditional
formatting. I want that in f2 it should return 40 and in f3 it should
return 25

Anybody to help. Its kinda Urgent


--
manan
------------------------------------------------------------------------
manan's Profile: http://www.excelforum.com/member.php...o&userid=34216
View this thread: http://www.excelforum.com/showthread...hreadid=541059

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      11th May 2006
Function PinkHeading(rng As Range, ci As Long)
Dim cell As Range
Application.Volatile
For Each cell In rng
If cell.Interior.ColorIndex = ci Then
PinkHeading = Application.Caller.Parent.Cells(1,
cell.Column).Value
Exit For
End If
Next cell
End Function


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"manan" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
>
> Hi
>
> I have a excel worksheet which has conditional formatting. If the
> condition is true it changes the background color of the cell to pink.I
> want a function so that it searchs a row and if any cell in that row is
> coloured pink then it should return the value of column heading at the
> end of the row.
>
> e.g
>
> a b c d e
> 1 20 25 30 40 50
> 2 TOM MOM SOM KOM JOM
> 3 MOM TOM KOM JOM SOM
>
> Lets assume b3 and d2 are highlighted in pink because of conditional
> formatting. I want that in f2 it should return 40 and in f3 it should
> return 25
>
> Anybody to help. Its kinda Urgent
>
>
> --
> manan
> ------------------------------------------------------------------------
> manan's Profile:

http://www.excelforum.com/member.php...o&userid=34216
> View this thread: http://www.excelforum.com/showthread...hreadid=541059
>



 
Reply With Quote
 
manan
Guest
Posts: n/a
 
      12th May 2006

hi bob
Thanks for ur reply
I am new to excel and not understanding the function.
Though i did understand that the range would be teh selection of row.
What should i selct for "ci". Is it the column heading selection. If it
is the selection of column heading then the function is not returning me
teh values.Instead showing error as VALUE
Also my column headings are not in row 1 they are in row 4.
Thanks


--
manan
------------------------------------------------------------------------
manan's Profile: http://www.excelforum.com/member.php...o&userid=34216
View this thread: http://www.excelforum.com/showthread...hreadid=541059

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      12th May 2006
ci should be the colorindex of the colour. For instance, Pink is 7, so for
instance you would use it like

=PinkHeading(4:4,7)

whic h will look for thr first pink cell in row 4, and return the value in
row 1 of that column. If your headings are in row 4, perhaps we should make
that optional, like this

Function PinkHeading(rng As Range, ci As Long, Optional headRow As Long = 1)
Dim cell As Range
Application.Volatile
For Each cell In rng
If cell.Interior.ColorIndex = ci Then
PinkHeading = Application.Caller.Parent _
.Cells(headRow, cell.Column).Value
Exit For
End If
Next cell
End Function

so you can pass the heading row, like

=PinkHeading(A16:M16,7,4)

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"manan" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
>
> hi bob
> Thanks for ur reply
> I am new to excel and not understanding the function.
> Though i did understand that the range would be teh selection of row.
> What should i selct for "ci". Is it the column heading selection. If it
> is the selection of column heading then the function is not returning me
> teh values.Instead showing error as VALUE
> Also my column headings are not in row 1 they are in row 4.
> Thanks
>
>
> --
> manan
> ------------------------------------------------------------------------
> manan's Profile:

http://www.excelforum.com/member.php...o&userid=34216
> View this thread: http://www.excelforum.com/showthread...hreadid=541059
>



 
Reply With Quote
 
manan
Guest
Posts: n/a
 
      12th May 2006

Hi Bob

Thanks a ton
It worked perfectly. It was really helpful.


--
manan
------------------------------------------------------------------------
manan's Profile: http://www.excelforum.com/member.php...o&userid=34216
View this thread: http://www.excelforum.com/showthread...hreadid=541059

 
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
A macro that counts cells when the conditional formatting formula =True. i.e. the cell is colored other than white. R Tanner Microsoft Excel Programming 5 19th Jun 2008 09:16 AM
Conditional Formatting selecting every formatted cell Cobra2140 Microsoft Excel Crashes 0 3rd Jun 2008 03:00 PM
Conditional formatting when cell value is top 3 of column . . . =?Utf-8?B?SHViaXRyb24yMDAw?= Microsoft Excel Misc 3 21st Mar 2006 09:39 PM
Count the number of times a cell is colored with conditional formatting DrSues02 Microsoft Excel Programming 3 20th Oct 2004 02:08 PM
Count the number of times a cell is colored with conditional formatting DrSues02 Microsoft Excel Programming 2 20th Oct 2004 01:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:53 PM.