Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Paul Sheppard
 
Posts: n/a
Default Question for bigwheel


Hi bigwheel

I am not very good at VBA and do not understand the reply you gave
below:

Try something like this. You can pick your own colors by changing the
ColorIndex or RGB values:-

Sub colorcode()
For nrow = 2 To 40000
If Cells(nrow, 2) = "G52-555222" Then
Range(Cells(nrow, 1), Cells(nrow, 7)).Interior.ColorIndex = 8
ElseIf Cells(nrow, 2) = "W5H-222999" Then
Range(Cells(nrow, 1), Cells(nrow, 7)).Interior.Color = RGB(255,
255, 192)
ElseIf Cells(nrow, 2) = "M52-999222" Then
Range(Cells(nrow, 1), Cells(nrow, 7)).Interior.Color = RGB(204,
255, 204)
Else
Range(Cells(nrow, 1), Cells(nrow, 7)).Interior.Color = RGB(255,
255, 255)
End If
Next
Range("a1").Select
End Sub

What in the code makes it change at every change in column 1? How would
this be adapted for changes in other columns? When it pastes in the
colours it removes the gridlines can it be donne without removing the
gridlines? What do "G52-555222", "W5H-222999", "M52-999222" mean/refer
to? What is nrow?

Sorry if I seen vague, but I find this a good way to learn

Thanks in advance Paul


--
Paul Sheppard
------------------------------------------------------------------------
Paul Sheppard's Profile: http://www.excelforum.com/member.php...o&userid=24783
View this thread: http://www.excelforum.com/showthread...hreadid=396683

  #2   Report Post  
bigwheel
 
Posts: n/a
Default

This particular reply was tailored in response to a posting on the excelforum
by mcnenny. In the example worksheet posted under the name €śShading
problem€ť, column 2 was headed €śAccount #€ť

Basically, what the macro does is starts at row 2 (row 1 assumed to be
column headings) and checks for an account # in column 2 (Cells(nrow,2) where
nrow is the counter in the For €¦ Next loop.) If the value is G52-555222, the
cells A2 to A7 are coloured, in this case, cyan. Otherwise, if the account
W5H-222999 is found, the row is coloured pale yellow etc. To adapt this for
other columns, change the 2 to 3 or 4 or whatever. The loop continues at the
Next statement and nrow is incremented to 3 and the whole thing starts over
but on row 3 until it reaches the end (in this case row 40000)

Blocks of colour will hide the gridlines but you can overcome this by
setting borders on all the cells

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
Newbie With A Question Michael Excel Worksheet Functions 0 July 28th 05 11:50 PM
Anybody Help with previous question Anthony Excel Discussion (Misc queries) 1 July 26th 05 01:26 PM
Hints And Tips For New Posters In The Excel Newsgroups Gary Brown Excel Worksheet Functions 0 April 15th 05 05:47 PM
Question about combining data from multiple workbooks into one rep BookOpenandUpright Excel Discussion (Misc queries) 2 February 19th 05 12:37 PM
An easy macro question and one I believe to be a little more diffi TroutKing Excel Worksheet Functions 3 January 18th 05 09:17 PM


All times are GMT +1. The time now is 10:22 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"