Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default CellColorIndex - not working

I tried to create the cell colour index function but it
gives #NAME? error.
Function CCOL(cell As Range) As Integer
Application.Volatile = True
CCOL = cell.Interior.ColorIndex.Value
End Function

Then I searched and copied function from the Chip's page
Function CellColorIndex(InRange As Range, Optional _
OfText As Boolean = False) As Integer
'
' This function returns the ColorIndex value of a the
Interior
' (background) of a cell, or, if OfText is true, of the
Font in the cell.
'
Application.Volatile True
If OfText = True Then
CellColorIndex = InRange(1,1).Font.ColorIndex
Else
CellColorIndex = InRange(1,1).Interior.ColorIndex
End If

End Function

This also gives the same error.

It means there is an obvious error or some setting needs
to be changed on my Excel. I am using Excel 2000.

Can somebody tell me whats wrong with it?

Thanks,
Malcom
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default CellColorIndex - not working

Hi
ythe added .value is the cause for this error. Try:
Function CCOL(cell As Range) As Integer
Application.Volatile = True
CCOL = cell.Interior.ColorIndex
End Function

Also put this code in a standard module and nOT in a worksheet module

--
Regards
Frank Kabel
Frankfurt, Germany

"Malcom Jazz" schrieb im Newsbeitrag
...
I tried to create the cell colour index function but it
gives #NAME? error.
Function CCOL(cell As Range) As Integer
Application.Volatile = True
CCOL = cell.Interior.ColorIndex.Value
End Function

Then I searched and copied function from the Chip's page
Function CellColorIndex(InRange As Range, Optional _
OfText As Boolean = False) As Integer
'
' This function returns the ColorIndex value of a the
Interior
' (background) of a cell, or, if OfText is true, of the
Font in the cell.
'
Application.Volatile True
If OfText = True Then
CellColorIndex = InRange(1,1).Font.ColorIndex
Else
CellColorIndex = InRange(1,1).Interior.ColorIndex
End If

End Function

This also gives the same error.

It means there is an obvious error or some setting needs
to be changed on my Excel. I am using Excel 2000.

Can somebody tell me whats wrong with it?

Thanks,
Malcom


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default CellColorIndex - not working

Malcom, try:

Function CCOL(cell As Range) As Integer
Application.Volatile
CCOL = cell.Interior.ColorIndex
End Function

Also, suggest you not use Application.Volatile unless you really need it.
If you are using the above function on a large number of cells, it has to
recalc every time you change a cell. Easier is to just to proess
ALT-CTL-F9, which forces a recalc when you need it.

Robert Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel


"Malcom Jazz" wrote in message
...
I tried to create the cell colour index function but it
gives #NAME? error.
Function CCOL(cell As Range) As Integer
Application.Volatile = True
CCOL = cell.Interior.ColorIndex.Value
End Function

Then I searched and copied function from the Chip's page
Function CellColorIndex(InRange As Range, Optional _
OfText As Boolean = False) As Integer
'
' This function returns the ColorIndex value of a the
Interior
' (background) of a cell, or, if OfText is true, of the
Font in the cell.
'
Application.Volatile True
If OfText = True Then
CellColorIndex = InRange(1,1).Font.ColorIndex
Else
CellColorIndex = InRange(1,1).Interior.ColorIndex
End If

End Function

This also gives the same error.

It means there is an obvious error or some setting needs
to be changed on my Excel. I am using Excel 2000.

Can somebody tell me whats wrong with it?

Thanks,
Malcom



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
CellColorIndex Steven Excel Worksheet Functions 3 October 1st 08 08:47 PM
Calculate working days but change working week SamB Excel Discussion (Misc queries) 1 September 1st 08 09:17 PM
Making weekend days working days - the system cuts the working tim Fluffy Excel Discussion (Misc queries) 1 May 30th 08 10:02 PM
Macro working in Excel 2003; not working in Excel 2000 Leslie Barberie Excel Programming 5 May 20th 04 07:51 PM
Adding sales from a non working day to the previous working day Alex Excel Programming 1 September 19th 03 08:48 AM


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

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"