PC Review


Reply
Thread Tools Rate Thread

Coloring Alternate lines

 
 
Jim Berglund
Guest
Posts: n/a
 
      31st May 2010
I want to color columns A to E on every other line.
I can't find an ISEVEN or ISINTEGER function, so how do I do That in VB?

Thanks,
Jim Berglund
 
Reply With Quote
 
 
 
 
Jim Berglund
Guest
Posts: n/a
 
      31st May 2010
I'm getting a Next without For error in the following code, and can't figure
out why...
BTW, If I get this fixed, will this code work for coloring alternate lines?
Jim


Sub SortAndColor()
Dim q, i As Long


With ActiveSheet
.Rows("1:1").Delete Shift:=xlUp
q = .Range("A" & Rows.Count).End(xlUp).Row
.Sort.SortFields.Clear
.Sort.SortFields.Add Key:=Range("E1:E" & q),
SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
.Sort.SortFields.Add Key:=Range("C1:C" & q),
SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
.Sort
.SetRange Range("A1:E" & q)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply


For i = 1 To q
If Int(i / 2) Then
.Range(Cells(i, 1), Cells(i, 5)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -4.99893185216834E-02
.PatternTintAndShade = 0
End With
Next

.PageSetup.PrintArea = "$A:$E"

End With

End Sub

"Jim Berglund" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I want to color columns A to E on every other line.
> I can't find an ISEVEN or ISINTEGER function, so how do I do That in VB?
> Thanks,
> Jim Berglund


 
Reply With Quote
 
sali
Guest
Posts: n/a
 
      31st May 2010
"Jim Berglund" <(E-Mail Removed)> je napisao u poruci interesnoj
grupi:(E-Mail Removed)...
> BTW, If I get this fixed, will this code work for coloring alternate
> lines?
> For i = 1 To q


> .Range(Cells(i, 1), Cells(i, 5)).Select
> With Selection.Interior


for i=1 to q step 2
will affect every-second-row [even or odd, depending on starting used]

you don't need range-select-with-selection, you may shortly:
with .Range(Cells(i, 1), Cells(i, 5)).interior



 
Reply With Quote
 
Jim Berglund
Guest
Posts: n/a
 
      31st May 2010
Thanks very much. I didn't even think of that!
Jim

"sali" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Jim Berglund" <(E-Mail Removed)> je napisao u poruci interesnoj
> grupi:(E-Mail Removed)...
>> BTW, If I get this fixed, will this code work for coloring alternate
>> lines?
>> For i = 1 To q

>
>> .Range(Cells(i, 1), Cells(i, 5)).Select
>> With Selection.Interior

>
> for i=1 to q step 2
> will affect every-second-row [even or odd, depending on starting used]
>
> you don't need range-select-with-selection, you may shortly:
> with .Range(Cells(i, 1), Cells(i, 5)).interior
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alternate Row Coloring Ned Microsoft Excel Misc 6 15th Jan 2010 01:23 PM
alternate line coloring on continuous form =?Utf-8?B?Sm9obkU=?= Microsoft Access Form Coding 3 30th Jan 2008 08:30 AM
Coloring alternate rows in a datasheet Cindy Microsoft Access Forms 1 19th Aug 2004 10:48 PM
Alternate row coloring David Turner Microsoft Excel Programming 10 8th Nov 2003 02:59 AM
Re: Coloring Alternate Lines in Access table Allen Browne Microsoft Access VBA Modules 0 5th Sep 2003 02:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:22 PM.