Very simple function used to work, but not now

zookeepertx

Well-known Member
Joined
May 27, 2011
Messages
589
Office Version
  1. 365
Platform
  1. Windows
A while back, I needed to be able to sort really long spreadsheets by the color that the cells were. So, someone showed me to create the following function:
Code:
Function GetColor(Mycell As Range)
GetColor = Mycell.Interior.ColorIndex
End Function
I would go to the first empty column to the right of my data & key in =GetColor(C7) & then autofill that down to the end of my data. This would fill the cells in that column with the number representing the color in C7 & I could then sort by that column.
Each month, I save the spreadsheet again in a new folder, for the new month's work & it has all worked perfectly for over a year! Now, suddenly, I get the error #NAME? in that column!
I wonder how one of my favorite "toys" got busted?? Can anyone help me fix it? I'll beg & grovel, if I have to, LOL!
 
Yep, only referring to one cell. I've retyped the formula in a couple of times, too.

Don't know where the Trust Center is, but I went to Options>Security>Security Level and that is set to Low. Is that the same thing? (Excel 2003 - aka "cave painting", LOL)
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
LOL. I totally forgot you had Excel 2003.
but yeah. That should be sufficient.

I'm afraid I do not know what the problem is..
as I am unable to recreate the situation.
 
Upvote 0
Okay- this is even weirder! I opened another workbook exactly the same, but for a different department; it has the same color-coding formula & it was working correctly.

I had VB open & happened to notice that the Function/Module (whatever) in that one was named Module1, while the one in the defective workbook was named GetColor. (I decided a while back that it'd be easier to spot if it had a "real" name).

Anyway, I changed the name to Module1 & now it works!! I even changed it back just to check & it didn't work; put it back to Module1 & it works! Strange! The formula doesn't refer to the module's name, so how would that affect it?
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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