PDA

View Full Version : [SOLVED:] Shading Every Other Row



LordDragon
08-15-2015, 06:55 AM
Greetings,

I would like to shade every other row on each sheet, but only from Column A to Column F.

I've tried several configurations of the following code, but nothing seems to work.



Sub ShadeRequired()
'Shades every other row.


'Declare the variables
Dim intRow As Long
'Dim rngCol As Range

'rngCol = ("A:F")
'With ActiveWorkbook.Worksheets("General Use Items").Range("A:F")
For intRow = 3 To 117 Step 2
Rows(intRow).Interior.Color = RGB(200, 200, 200)
Next intRow
'End With
End Sub


It could be my Workbook too, because even when I remove any limitations to the code about the column range, it still doesn't work.

Any ideas would be appreciated.

LordDragon
08-15-2015, 08:09 AM
Update:

This code works to shade the rows.


Sub ShadeRequired()
'Shades every other row of required parts.


'Declare the variables
Dim intRow As Long
'Dim rngCol As Range

'rngCol = ("A:F")
With ActiveWorkbook.Worksheets("General Use Items").Range("A:F")
For intRow = 3 To 117 Step 2
Rows(intRow).Interior.Color = RGB(200, 200, 200)
Next intRow
End With
End Sub


But is does not only shade from Column A to F, it shades the entire row.

How do I get it to only shade the part I want?

LordDragon
08-15-2015, 08:35 AM
This code did it.



Sub ShadeRequired()
'Shades every other row of required parts.


'Declare the variables
Dim lngRow As Long
Dim lngCol As Long

With ActiveWorkbook.Worksheets("General Use Items")
For lngCol = 1 To 6
For lngRow = 3 To 117 Step 2
Cells(lngRow, lngCol).Interior.Color = RGB(200, 200, 200)
Next lngRow
Next lngCol
End With
End Sub

snb
08-15-2015, 02:07 PM
Sub M_snb()
Sheet1.usedrange.Select
Sheet1.ListObjects.Add 1, , , xlNo
End Sub

LordDragon
08-15-2015, 02:32 PM
Thanks snb, I like that suggestion, it's short, sweet and to the point.

I think I stick with the one I came up with though. Thinking ahead of the changes I'm planning for this workbook, I'm considering putting a few different color options in based on the importance of the parts and allowing the user to change the color.

Then I'll be figuring out how to make it auto-sort the sheet based on the cell colors.