change macro that changes interior color

still learning

Well-known Member
Joined
Jan 15, 2010
Messages
843
Office Version
  1. 365
Platform
  1. Windows
Hi
A few years ago, I made this macro with the help of this forum.
What it does is fill every other row interior from A to I with a blue shade
It starts at A3 , then stops at the last cell in A that has data.
Then it moves the cursor to the last cell in A and moves down one.
VBA Code:
Sub filleveryotherrow ()
‘ change interior color
Dim i As Long
  For i = 3 To Columns("A:I").Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row Step 2
    With Rows(i).Resize(, 9).Interior
      .Pattern = xlSolid
      .PatternColorIndex = xlAutomatic
      .Color = 16772049
      .TintAndShade = 0
      .PatternTintAndShade = 0
    End With
  Next i
lastrow
End Sub
VBA Code:
Sub lastrow()
' find last row
x = Range("A" & Rows.Count).End(xlUp).row
Range("A" & x + 1).Select
    Selection.End(xlUp).Select
ActiveWindow.ScrollRow = ActiveCell.row - 12
ActiveCell.Offset(1, 0).Range("A1").Select   
End Sub
What I don’t know how to do is add the following at the beginning.
VBA Code:
  For i = 3 To Columns("A:I").Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row Step 2
    With Rows(i).Resize(, 9).Interior
‘ this will un color each line
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0 
 End With
  Next i
What I want to do is first change the interior of all the rows to “no color”, then make every other row light blue
What happens is when I add data and then use sort, the row colors “get at of wack”
This will un-color ever row with data and then make every other row light blue.
What I do now is highlight it all and change the interior to no color
Then I run the fill…macro

mike
 
Hi
A few years ago, I made this macro with the help of this forum.
What it does is fill every other row interior from A to I with a blue shade
It starts at A3 , then stops at the last cell in A that has data.
Then it moves the cursor to the last cell in A and moves down one.
VBA Code:
Sub filleveryotherrow ()
‘ change interior color
Dim i As Long
  For i = 3 To Columns("A:I").Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row Step 2
    With Rows(i).Resize(, 9).Interior
      .Pattern = xlSolid
      .PatternColorIndex = xlAutomatic
      .Color = 16772049
      .TintAndShade = 0
      .PatternTintAndShade = 0
    End With
  Next i
lastrow
End Sub
VBA Code:
Sub lastrow()
' find last row
x = Range("A" & Rows.Count).End(xlUp).row
Range("A" & x + 1).Select
    Selection.End(xlUp).Select
ActiveWindow.ScrollRow = ActiveCell.row - 12
ActiveCell.Offset(1, 0).Range("A1").Select  
End Sub
What I don’t know how to do is add the following at the beginning.
VBA Code:
  For i = 3 To Columns("A:I").Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row Step 2
    With Rows(i).Resize(, 9).Interior
‘ this will un color each line
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
 End With
  Next i
What I want to do is first change the interior of all the rows to “no color”, then make every other row light blue
What happens is when I add data and then use sort, the row colors “get at of wack”
This will un-color ever row with data and then make every other row light blue.
What I do now is highlight it all and change the interior to no color
Then I run the fill…macro

mike
You could use a table and then alternate rows will be coloured or use a Conditional Formatting formula : =MOD(ROW(),2)=0
 
Upvote 0
Solution
Hi HighandwWilder
I'll look into that
If I can't use it, I'll make up a sample sheet and post it
thanks for the reply

mike
 
Upvote 0

Forum statistics

Threads
1,226,771
Messages
6,192,919
Members
453,767
Latest member
922aloose

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top