Forum Discussion
Devon1990
Nov 06, 2023Copper Contributor
Excel Autofill by color
How do you autofill cells that have a certain color? I have thousands of red cells that need a formula in the cell boundaries and they are not directly above or below one another. They are scattered,...
OliverScheurich
Nov 07, 2023Gold Contributor
Sub formula()
Dim cell, rng As Range
Set rng = Selection
For Each cell In rng
If cell.Interior.ColorIndex = 3 Then
cell.formula = "=today()"
Else
End If
Next cell
End SubIs this similar to what you are looking for? You can select a range with the mouse or with ctrl+G. Then you can run the macro and the code inserts the TODAY() formula in all red cells (Interior.ColorIndex = 3) within the selected range.
Devon1990
Nov 10, 2023Copper Contributor
The other thing is that I want it to do what happens when you drag to autofill. The cell you drag auto adjusts the formula reference location too. I don't know how else to explain it, so hopefully that helps.