1

I have few cells colored in Range ("I1:I100"). I need to color the entire row .I have VBA recorded for that but it shows some error.

ActiveSheet.Range("I1:I100").AutoFilter Field:=1, Criteria1:=RGB(255, 255 _
    , 0), Operator:=xlFilterCellColor
Rows.Activate.Select
With Selection.Interior
    .PatternColorIndex = xlAutomatic
    .Color = 65535
    .TintAndShade = 0
    .PatternTintAndShade = 0
End With
ActiveSheet.Range("$A$1:$G$9").AutoFilter Field:=1

but is it possible to have a SIMPLE code by declaring the variables.

Community
  • 1
  • 1
David Syriac
  • 65
  • 1
  • 10
  • what is the error? What is the condition that determine when the rows are to be coloured, or is it all rows? Do you really mean the entire row (not advisable) or your entire row of data in which case what is the last column of your data to be coloured. – Forward Ed May 11 '16 at 17:54
  • @ForwardEd that's the main challenge while recording it takes rows (..) but it will vary for different works that's y I have tried putting active rows after filter – David Syriac May 11 '16 at 18:01
  • Sorry missed the entire line with the autofilter in it. you would think by 2 pm I would be awake! – Forward Ed May 11 '16 at 18:07

1 Answers1

1

Rows.Activate.Select is where your error is happening, as you can't do .Activate.Select. Please read through How to avoid using .Select/.Activate, and try the below:

Sub t()
' What's this next line supposed to do?
'ActiveSheet.Range("I1:I100").AutoFilter Field:=1, Criteria1:=RGB(255, 255 _
    , 0), Operator:=xlFilterCellColor

With Rows("1:100").Interior
    .PatternColorIndex = xlAutomatic
    .Color = 65535
    .TintAndShade = 0
    .PatternTintAndShade = 0
End With
ActiveSheet.Range("$A$1:$G$9").AutoFilter Field:=1
End Sub
Community
  • 1
  • 1
BruceWayne
  • 22,923
  • 15
  • 65
  • 110