haleybusche
New Member
- Joined
- Mar 7, 2011
- Messages
- 13
I am not great with excel macros, so what I think I need is a dynamic array.
I have created a function that assigns the color of a cell to a number, and I need to store that number somewhere so that I can sort by it later.
The number of cells with colors that need to be assigned a number and stored, is dynamic.
Below is the function that assigns the color of the cell to a number
I need help with code that will store that number. The color of the cell can also change, so I need the number to be updated when the color changes and be restored.
I also need help with the code that will then allow me to sort those numbers.
I know this is a little different, so if further discussion is necessary please feel free.
Thanks
Haley
I have created a function that assigns the color of a cell to a number, and I need to store that number somewhere so that I can sort by it later.
The number of cells with colors that need to be assigned a number and stored, is dynamic.
Below is the function that assigns the color of the cell to a number
Code:
Function GetColor(rngIndex As Range, rngSource As Range) As Long
Dim lngColor As Long
Dim J As Integer
Application.Volatile
lngColor = rngSource.Interior.ColorIndex
GetColor = 99 'Set to default color
For J = 1 To rngIndex.Count
If rngIndex(J).Interior.ColorIndex = lngColor Then
GetColor = J
End If
Next J
End Function
I need help with code that will store that number. The color of the cell can also change, so I need the number to be updated when the color changes and be restored.
I also need help with the code that will then allow me to sort those numbers.
I know this is a little different, so if further discussion is necessary please feel free.
Thanks
Haley