i'm new to excel vba and even newer to this forum so i'll appreciate any help to guide me along!
i have a code to do the following steps:
1) find a cell in Sheets("Phases")
2) Reference a cell relative to it
3) Use the fill colour (is interior.colourindex correct?) of this reference cell as a basis for comparison
4) Move the selected cell down if the colour is the same as the reference colour
1) currently i have a run time error. it seems that the error is at the cells.find part when i debug it. what should i do?
2) is my code correct to compare the fill colour of a cell and then set it as a basis of comparison?
3) also, i have another sub (not shown here) which also has "dim target as Range". is it possible to reuse the same word? or is that the cause of the error in the first place?
*thanks to wigi for putting in code tags
Sub findformatting() Dim colouredcell As Range Dim cellCol As Long Dim target As String Sheets("Phases").Select target = "Phase 1" 'change the target to whatever u wanna find Cells.Find(What:=target, After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False).Activate Set colouredcell = ActiveCell.Offset(2, 0) 'go to my reference cell cellCol = colouredcell.Interior.ColorIndex 'reference cell colour 'use the fill colour of this reference cell as the reference colour While colouredcell.Interior.ColorIndex = cellCol = True Set colouredcell = colouredcell.Offset(1, 0) Wend 'moves the cell being selected down colouredcell.Select End Sub