.Interior.ColorIndex

ausch

New Member
Joined
Jan 4, 2012
Messages
2
Hello,

I am using Excel2000 on a windowsXP machine. I have the following function.

Public Function testing(dataRange As Range)
Dim cell As Range

For Each cell In dataRange
cell.Interior.ColorIndex = 8
Next cell
End Function

The function works fine when it is used with the 'call' statement within a macro ie like the test subroutine below.

Sub test()
Call testing(ActiveSheet.Range("k1:k10"))
End Sub

When I call the function from a cell in excel eg in cell a1 I have the formula "=testing("k1:k10")". The cells are not colored.

Has somebody else found this problem?

thanks in advance

ausch
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
UDF functions cannot change formatting, they only return a value that can be stored in .Value, .Value2, .Text or .FormulaR1C1

To achieve what you are trying to do, you would need to put the range address in a cell and then call a macro that referenced that cell.

Your function should be a procedure.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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