Color filled cells

KnAsTa

Board Regular
Joined
Apr 11, 2002
Messages
52
G'day,

Can anyone field this question for me?

i want to know how to keep colour filled cells fixed in place. So, if u wanted to "sort" your spreadsheet, the filled cells would not move, only the data would move.

Thanx guys!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try the following macros:

Code:
Public addresses(1000), colors(1000)
Sub SaveColors()
Dim i As Integer
For Each Cell In ActiveSheet.UsedRange
addresses(i) = Cell.Address
colors(i) = Cell.Interior.ColorIndex
i = i + 1
Next
End Sub
Sub UpdateColors()
ActiveSheet.UsedRange.ClearFormats
For i = 0 To 1000
On Error GoTo 1
Range(addresses(i)).Interior.ColorIndex = colors(i)
Next
1 End Sub

Run SaveColors before you sort and then run UpdateColors after you have sorted. The "1000" is just a number I chose to guess how many cells you have. You can increase or decrease as needed.
 
Upvote 0
Hi KnAsTa,

You can do this using conditional formatting.

If you want columns A-G in row 4 to be a blue background

Select the cells in A-G in row 4.
Format Conditional Formatting
In the 1st Drop Down change from Cell Value is to Formula is
In the next box enter:
=row()=row()

Next click the format box choose the patterns tab and select the colour of your choice.

Click OK
Click OK

This can now be sorted and will not move.

This formatting can be copied and since the condition is always true will show the colour of your choice.
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,442
Members
448,898
Latest member
drewmorgan128

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