Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default How to set row color

Dear all,

I have code as follows:

k = 0
For i = 0 To rs.RecordCount - 1
k = k + 2
For j = 0 To rs.Fields.Count - 1

Sheet1.Cells(k + 5, j + 1) = rs.Fields(j).Value
' How to add code to change the row of k+5

Next j

rs.movenext
next i

In the above code, I want to change the row color of rows
k+5 to green. How can I do that?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default How to set row color

This will paint it green but you will have to add in the conditions you want
to exist.
e.g. If... Then

Worksheets(2).Cells(k + 5, j + 1).EntireRow.Interior.ColorIndex = 4

End If

"hon123456" wrote:

Dear all,

I have code as follows:

k = 0
For i = 0 To rs.RecordCount - 1
k = k + 2
For j = 0 To rs.Fields.Count - 1

Sheet1.Cells(k + 5, j + 1) = rs.Fields(j).Value
' How to add code to change the row of k+5

Next j

rs.movenext
next i

In the above code, I want to change the row color of rows
k+5 to green. How can I do that?

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default How to set row color

Be careful putting that code in a For...Next loop. You could paint every
line that meet your For selection criteria. If this is what you want then
forget the If ... then statement and just use the command line.

"JLGWhiz" wrote:

This will paint it green but you will have to add in the conditions you want
to exist.
e.g. If... Then

Worksheets(2).Cells(k + 5, j + 1).EntireRow.Interior.ColorIndex = 4

End If

"hon123456" wrote:

Dear all,

I have code as follows:

k = 0
For i = 0 To rs.RecordCount - 1
k = k + 2
For j = 0 To rs.Fields.Count - 1

Sheet1.Cells(k + 5, j + 1) = rs.Fields(j).Value
' How to add code to change the row of k+5

Next j

rs.movenext
next i

In the above code, I want to change the row color of rows
k+5 to green. How can I do that?

Thanks


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't format cell color/text color in Office Excel 2003 in fil Tony S Excel Discussion (Misc queries) 1 December 21st 07 01:41 PM
change fill color of a range of cells based on color of a cell? DarMelNel Excel Programming 0 March 2nd 06 06:35 PM
Can't format cell color/text color in Office Excel 2003 in files . albertaman Excel Discussion (Misc queries) 0 February 16th 06 03:56 AM
My fill color and font color do not work in Excel Std Edition 2003 chapstick Excel Discussion (Misc queries) 1 September 11th 05 08:48 PM
Browse Forms Controls and change TextBox color based on cell color StefanW Excel Programming 2 November 21st 04 07:06 PM


All times are GMT +1. The time now is 05:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"