Function to return range for future processing

Rolly_Sefu

Board Regular
Joined
Oct 25, 2013
Messages
149
Hello,

I have created a function that return the cell color

VBA Code:
Function GetFillColor(WorkRng As Range)
    GetFillColor= WorkRng.Interior.ColorIndex
End Function

This works perfectly.

I need to convert this to return a range of numbers ex: "{1;2;3;4}" ( its a if you select a range and hit F9 ), in order to apply the formula: "=Max((GetFillColor(A1:A5)=15)*ROW(A1:A5))" in order the get the last specific colored cell.

Anyone have an idea ?
Thank you.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hello, just looked at the link you provided, but does not help me, i need whole array to stay in the formula: "={15;-4142;15;-4142}" so i can apply my next formula
 
Upvote 0
How about
VBA Code:
Function GetFillColor(WorkRng As Range) As Variant
   Dim Cl As Range
   Dim i As Long
   ReDim Ary(1 To WorkRng.Count, 1 To 1)
   
   For Each Cl In WorkRng
      i = i + 1
      Ary(i, 1) = Cl.Interior.ColorIndex
   Next Cl
   GetFillColor = Ary
End Function
 
Upvote 0
Solution
That's the method in the link I provided. (shrug)
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top