ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro to highlight every second row within the current region (https://www.excelbanter.com/excel-programming/389219-macro-highlight-every-second-row-within-current-region.html)

markx

macro to highlight every second row within the current region
 
Hello everybody,

Do you know how to highlight every second row withing the
ActiveCell.CurrentRegion area with a macro (not conditional formatting)?

Thanks for your help!
Regards,
Mark



[email protected]

macro to highlight every second row within the current region
 
Hi
Sub tester()
Dim myrange As Range
Dim i As Long
On Error Resume Next 'incase you run off the end
Set myrange = ActiveCell.CurrentRegion
For i = 2 To myrange.Rows.Count Step 2
myrange.Rows(i).Interior.ColorIndex = 6
Next i
On Error GoTo 0
End Sub

regards
Paul

On May 11, 10:26 am, "markx" wrote:
Hello everybody,

Do you know how to highlight every second row withing the
ActiveCell.CurrentRegion area with a macro (not conditional formatting)?

Thanks for your help!
Regards,
Mark




JE McGimpsey

macro to highlight every second row within the current region
 
One way:

Public Sub CurrentRegionShadeEveryOtherRow()
Dim i As Long
With ActiveCell.CurrentRegion
.Interior.ColorIndex = xlColorIndexNone
For i = 1 To .Rows.Count Step 2
.Cells(i, 1).Resize(1, .Columns.Count).Interior.ColorIndex = 6
Next i
End With
End Sub


In article ,
"markx" wrote:

Hello everybody,

Do you know how to highlight every second row withing the
ActiveCell.CurrentRegion area with a macro (not conditional formatting)?

Thanks for your help!
Regards,
Mark


Dave Peterson

macro to highlight every second row within the current region
 
You may want to glimpse at Format|autoformat, too.

If you like one, you could record a macro while you do it manually. Remember to
click that Options button to use the settings you like.

markx wrote:

Hello everybody,

Do you know how to highlight every second row withing the
ActiveCell.CurrentRegion area with a macro (not conditional formatting)?

Thanks for your help!
Regards,
Mark


--

Dave Peterson

markx

macro to highlight every second row within the current region
 
Thanks for all three proposals guys, they work OK!
For the Format/Auto Format..., I was not at all aware of this option until
now, learned something new :-)

"Dave Peterson" wrote in message
...
You may want to glimpse at Format|autoformat, too.

If you like one, you could record a macro while you do it manually.
Remember to
click that Options button to use the settings you like.

markx wrote:

Hello everybody,

Do you know how to highlight every second row withing the
ActiveCell.CurrentRegion area with a macro (not conditional formatting)?

Thanks for your help!
Regards,
Mark


--

Dave Peterson





All times are GMT +1. The time now is 01:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com