I'm trying to delete all cells that have the same interior color in an Excel 2010 worksheet using the following code:
Dim myRange As Range
Set myRange = Application.InputBox("Select a cell to remove based on background fill color.", Type:=8)
Range("C3").Interior.Color = Range(myRange).Interior.Color
But when I run the code, I get the following error:
Method 'Range' of object '_Global' failed.
I've figured out that even though I'm asking for the cell reference as a range object (Type:=8
), myRange
is being set to the value of the cell. For example, the value in A2
is "Test." myRange
should come back asA2
, but it's coming back as "Test." Any idea why that would be?