Copy/paste cell if Cell has it's a color Filled

ashringg

New Member
Joined
Nov 2, 2023
Messages
13
Office Version
  1. 2016
Platform
  1. Windows
Hi Savvy People,

I'm trying to write a macro which would automatically:
  1. Copy cells that have a fill color
  2. Paste those filled color cells (with contents, the color but not the number format) to a list on the same sheet- is different column or section
Note: there multiple fill colors.

Would you be able to assist? Any tips would help.

Yearly Calendar Macro Template AD.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAH
12024
2January '24February '24March '24April '24RGB Color
3SMTWTFSSMTWTFSSMTWTFSSMTWTFS252, 213, 180250, 191, 143
412345612312123456216, 228, 188196, 215, 155
57891011121345678910345678978910111213255, 255, 204255, 255, 0
614151617181920111213141516171011121314151614151617181920183, 222, 232146, 205, 220
721222324252627181920212223241718192021222321222324252627204, 192, 218177, 160, 199
828293031252627282924252627282930282930217, 217, 217191, 191, 191
931221, 217, 196196, 189, 151
10May '24June '24July '24August '24
11SMTWTFSSMTWTFSSMTWTFSSMTWTFSList
1212341123456123Date
13567891011234567878910111213456789102/13/2024
1412131415161718910111213141514151617181920111213141516172/16/2023
15192021222324251617181920212221222324252627181920212223243/19/2024
162627282930312324252627282928293031252627282930313/20/2024
17304/22/2024
18September '24October '24November '24December '244/23/2024
19SMTWTFSSMTWTFSSMTWTFSSMTWTFS6/10/2024
201234567123451212345676/11/2024
21891011121314678910111234567898910111213147/22/2024
221516171819202113141516171819101112131415161516171819202111/19/2024
2322232425262728202122232425261718192021222322232425262728
242930272829303124252627282930293031
25
2024 (2)
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Have a try with my macro:
VBA Code:
Option Explicit
Sub test()
    Dim Cell As Range
    Dim DestRowCount As Long
    Dim DestNewRow As Long
    Application.ScreenUpdating = False
    DestNewRow = 13
    DestRowCount = Cells(Rows.Count, "AH").End(xlUp).Row
    If DestRowCount < 13 Then DestRowCount = 13
    Range("AH" & DestNewRow & ":AH" & DestRowCount).Clear
    For Each Cell In Range("A4:AE24").Cells
        If Cell.Interior.ColorIndex <> xlNone Then
            Cell.Copy Range("AH" & DestNewRow)
            Range("AH" & DestNewRow).NumberFormat = "dd/mm/yyyy" '<- here check your local format for dates
            DestNewRow = DestNewRow + 1
        End If
    Next Cell
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution
Thanks for the positive feedback(y), glad having been of some help.
By the way, you probably need to mark this thread as 'Solved'.
 
Upvote 1
When I run the Marco, my formula CountColorIf formula messes up. I have to go into the cell to fix it. Do you have any suggestions?
 
Upvote 0
Sorry, can't be of any help, I have no idea which cells have a formula with the CountColorIf function and how you're using it since you haven't, until now, attached a fully functional file; what you attached in post #1 (Code XL2BB) doesn't contain formulas that can be evaluated.
In any case, the macro copies from the calendar only the dates of the cells that have a background color to the list area without interfering with any other detail of your sheet so it can't be the cause of the issue.
 
Last edited:
Upvote 1

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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