Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Interrogating format

How would I go about interrogating the format and/or custom format of a
cell, please? I am assuming that this has to be done by VBA hence I have
only posted the question in this newsgroup, but if there is a non-VBA
solution I would be interested.

Examples might be:

1) A function: =FUNC(cell_ref) should return the text string "green" if the
background colour of cell_ref is green

2) I might want to sort a range of cells by the background colour of cells
in Column B.

There are numerous other possibilities, so I am only looking for general
pointers (or a URL that may explain it in depth).

Thanks.

--
Return email address is not as DEEP as it appears


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Interrogating format



Try:

Function CellColor(Optional Reference As Range) As Long

If Reference Is Nothing Then Set Reference = Application.Caller
With Reference.Cells(1).Interior
If .ColorIndex = xlColorIndexNone Then
CellColor = 0
Else
CellColor = .ColorIndex
End If
End With

End Function


I wouldn't specify volatile.. Changing a cells color does NOT trigger
a change event. So before sorting you'll have to force a recalc.



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Jack Schitt" wrote:

How would I go about interrogating the format and/or custom format of
a cell, please? I am assuming that this has to be done by VBA hence I
have only posted the question in this newsgroup, but if there is a
non-VBA solution I would be interested.

Examples might be:

1) A function: =FUNC(cell_ref) should return the text string "green"
if the background colour of cell_ref is green

2) I might want to sort a range of cells by the background colour of
cells in Column B.

There are numerous other possibilities, so I am only looking for
general pointers (or a URL that may explain it in depth).

Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Interrogating format

Thanks for that.

"keepitcool" wrote in message
...


Try:

Function CellColor(Optional Reference As Range) As Long

If Reference Is Nothing Then Set Reference = Application.Caller
With Reference.Cells(1).Interior
If .ColorIndex = xlColorIndexNone Then
CellColor = 0
Else
CellColor = .ColorIndex
End If
End With

End Function


I wouldn't specify volatile.. Changing a cells color does NOT trigger
a change event. So before sorting you'll have to force a recalc.



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Jack Schitt" wrote:

How would I go about interrogating the format and/or custom format of
a cell, please? I am assuming that this has to be done by VBA hence I
have only posted the question in this newsgroup, but if there is a
non-VBA solution I would be interested.

Examples might be:

1) A function: =FUNC(cell_ref) should return the text string "green"
if the background colour of cell_ref is green

2) I might want to sort a range of cells by the background colour of
cells in Column B.

There are numerous other possibilities, so I am only looking for
general pointers (or a URL that may explain it in depth).

Thanks.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lock Cell Format - Allow copy and paste of data without format change Chris12InKC Excel Worksheet Functions 2 May 9th 23 07:42 PM
Need help with converting CUSTOM format/TEXT format to DATE format Deo Cleto Excel Worksheet Functions 6 June 2nd 09 08:14 PM
Interrogating cells by cell formatting Bhupinder Rayat Excel Worksheet Functions 2 September 26th 05 11:32 AM
Interrogating Data in Excel Daniel Dewes New Users to Excel 1 March 21st 05 11:47 PM
how to format excel format to text format with separator "|" in s. azlan New Users to Excel 1 January 31st 05 12:57 PM


All times are GMT +1. The time now is 09:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"