Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Macro Help - Array

I have this simple function to capture back ground color of a cell.

Function BGCol(refRange As Range)
BGCol = refRange.Interior.ColorIndex
End Function

I want to convert this to an array function where that array can store
colorindex for all the cells in a specified range and then i can use it in a
sumproduct formula to fins cells with a certain color.

Any help or direction appreciated.

Best,

RK
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Macro Help - Array

Take a look at http://www.xldynamic.com/source/xld.ColourCounter.html, that
is exactly what I do there.

--

HTH

Bob

"rk0909" wrote in message
...
I have this simple function to capture back ground color of a cell.

Function BGCol(refRange As Range)
BGCol = refRange.Interior.ColorIndex
End Function

I want to convert this to an array function where that array can store
colorindex for all the cells in a specified range and then i can use it in
a
sumproduct formula to fins cells with a certain color.

Any help or direction appreciated.

Best,

RK



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Macro Help - Array

Try

Function BGColors(RR As Range) As Long()
Dim Arr() As Long
Dim RNdx As Long
Dim CNdx As Long
ReDim Arr(1 To RR.Rows.Count, 1 To RR.Columns.Count)
For RNdx = 1 To RR.Rows.Count
For CNdx = 1 To RR.Columns.Count
Arr(RNdx, CNdx) = RR(RNdx, CNdx).Interior.ColorIndex
Next CNdx
Next RNdx
BGColors = Arr
End Function

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com



On Thu, 25 Mar 2010 15:20:03 -0700, rk0909
wrote:

I have this simple function to capture back ground color of a cell.

Function BGCol(refRange As Range)
BGCol = refRange.Interior.ColorIndex
End Function

I want to convert this to an array function where that array can store
colorindex for all the cells in a specified range and then i can use it in a
sumproduct formula to fins cells with a certain color.

Any help or direction appreciated.

Best,

RK

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Macro Help - Array

works exactly as i wished. awesome!
thanks so much.

"Chip Pearson" wrote:

Try

Function BGColors(RR As Range) As Long()
Dim Arr() As Long
Dim RNdx As Long
Dim CNdx As Long
ReDim Arr(1 To RR.Rows.Count, 1 To RR.Columns.Count)
For RNdx = 1 To RR.Rows.Count
For CNdx = 1 To RR.Columns.Count
Arr(RNdx, CNdx) = RR(RNdx, CNdx).Interior.ColorIndex
Next CNdx
Next RNdx
BGColors = Arr
End Function

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com



On Thu, 25 Mar 2010 15:20:03 -0700, rk0909
wrote:

I have this simple function to capture back ground color of a cell.

Function BGCol(refRange As Range)
BGCol = refRange.Interior.ColorIndex
End Function

I want to convert this to an array function where that array can store
colorindex for all the cells in a specified range and then i can use it in a
sumproduct formula to fins cells with a certain color.

Any help or direction appreciated.

Best,

RK

.

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
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R[_2_] Excel Programming 3 November 13th 07 04:08 PM
array formula in macro ezil Excel Programming 3 August 11th 07 12:00 PM
formula array in a macro Tanya Excel Programming 3 May 16th 07 11:47 AM
How to use an array function in a macro Bharath Rajamani Excel Programming 3 August 2nd 06 09:22 PM
Macro to sum array by date Joe Blow Excel Worksheet Functions 5 January 21st 05 11:05 PM


All times are GMT +1. The time now is 11:52 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"