Hi guys.
I've found online a VBA made by p45cal which scrolls the view to the next colored cell in a selected column and it's working fine, but I would like to make some tweaks to it.
If someone will have some time and could take a look at this I will really appreciate the help. I've tried to sort it out myself, but my knowledge of VBA is very limited.
Best regards,
Tom.
I've found online a VBA made by p45cal which scrolls the view to the next colored cell in a selected column and it's working fine, but I would like to make some tweaks to it.
- Right now it is scrolling to the next colored cell as it should, but I would like to modify it to make it scrolling to the next different color, for e.g. we have a column in which we have:
C2 - red background fill
C3 - red background fill
C4 - yellow background fill
right now it will jump from C2 to C3. I would like to make it scroll to C4 as its the next different color. - It does not treat No Fill as a color. If it is possible I would like to change that.
VBA Code:
Sub AnyColour()
Dim StartCellDefined As Boolean
Set ur = ActiveSheet.UsedRange
If Intersect(ur, ActiveCell) Is Nothing Then
StartCellDefined = True
Else
rw = ActiveCell.Row - ur.Row + 1
Colm = ActiveCell.Column - ur.Column + 1
End If
For myRw = 1 To ur.Rows.Count
For myColm = 1 To ur.Columns.Count
If Not StartCellDefined Then
myRw = rw
myColm = Colm + 1
StartCellDefined = True
End If
If ur.Cells(myRw, myColm).Interior.ColorIndex <> xlNone Then
ur.Cells(myRw, myColm).Activate
Exit Sub
End If
Next myColm
Next myRw
For myRw = 1 To ur.Rows.Count
For myColm = 1 To ur.Columns.Count
If myRw = rw And myColm = Colm Then
EndReached = True
Exit For
End If
If ur.Cells(myRw, myColm).Interior.ColorIndex <> xlNone Then
ur.Cells(myRw, myColm).Activate
Exit Sub
End If
Next myColm
If EndReached Then Exit For
Next myRw
End Sub
If someone will have some time and could take a look at this I will really appreciate the help. I've tried to sort it out myself, but my knowledge of VBA is very limited.
Best regards,
Tom.