Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default comparing and painting cells


hello... if i have the following situation on the seet:


1 0 40,00 20,00 20,00 20,00
2 0 30,00 20,00 20,00 30,00
1 10,00 20,00 40,00 30,00 0
2 20,00 30,00 50,00 0 0


in the "1" row i just want to paint the cell blue and save it to
compare later....
in the 2 row if the value is less than or equal to the value saved in
the same column in the previus row i want it green, if its greater i
want it red

in either rows if i have a "0" value i just want to paint the cell
plain white

the columns are E to Q but the rows range is not defined, but for a 1
row ill always have a 2 row, and it will start with a 1 row.......

can some one help me there plis??

i can program, but not in VBA, if someone just give me a light where i
can find something that can start me up and i take some ideias i can
program myself, that would do too

the algorith would be something like the following

For each cell in the range(E:Q) do
if cell value = 0 then
paint the cell white
else if cell in the first column is 1 then
paint the cell blue
else if cell in the first column is 2
if cell value is less than or equal to the cell in the previus row and
same column
paint the cell green
else if value is greater than the cell in the previus row and same
column
paint the cell red
next cell

thank you


--
redf1re
------------------------------------------------------------------------
redf1re's Profile: http://www.excelforum.com/member.php...o&userid=31258
View this thread: http://www.excelforum.com/showthread...hreadid=511141

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default comparing and painting cells


geez.... my spaces went to hell

For each cell in the range(E:Q) do
if cell value = 0 then
.........paint the cell white
else if cell in the first column is 1 then
...........paint the cell blue
else if cell in the first column is 2
...........if cell value is less than or equal to the cell in the
previus row and same column
.......................paint the cell green
...........else if value is greater than the cell in the previus row
and same column
........................paint the cell red
next cell


--
redf1re
------------------------------------------------------------------------
redf1re's Profile: http://www.excelforum.com/member.php...o&userid=31258
View this thread: http://www.excelforum.com/showthread...hreadid=511141

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default comparing and painting cells


geez.... my spaces went to hell

For each cell in the range(E:Q) do
if cell value = 0 then
.........paint the cell white
else if cell in the first column is 1 then
...........paint the cell blue
else if cell in the first column is 2
...........if cell value is less than or equal to the cell in the
previus row and same column
.......................paint the cell green
...........else if value is greater than the cell in the previus row
and same column
........................paint the cell red
next cell


--
redf1re
------------------------------------------------------------------------
redf1re's Profile: http://www.excelforum.com/member.php...o&userid=31258
View this thread: http://www.excelforum.com/showthread...hreadid=511141

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default comparing and painting cells

Hi,
Try this as a starter:

Sub PaintCells()

Dim lastrow As Long, r As Long, c As Integer

With Worksheets("Sheet1")

lastrow = .Cells(Rows.Count, "E").End(xlUp).Row

For r = 2 To lastrow ' <=== assumes data starts in row 2

Select Case .Cells(r, "A")

Case Is = 1
For c = 5 To 17
If .Cells(r, c) < 0 Then
.Cells(r, c).Interior.ColorIndex = 5
End If
Next c

Case Is = 2
For c = 5 To 17
If .Cells(r, c) < 0 Then
If .Cells(r, c) <= .Cells(r - 1, c) Then
.Cells(r, c).Interior.ColorIndex = 4
Else
.Cells(r, c).Interior.ColorIndex = 3
End If
End If
Next c

End Select

Next r

End With
End Sub

"redf1re" wrote:


hello... if i have the following situation on the seet:


1 0 40,00 20,00 20,00 20,00
2 0 30,00 20,00 20,00 30,00
1 10,00 20,00 40,00 30,00 0
2 20,00 30,00 50,00 0 0


in the "1" row i just want to paint the cell blue and save it to
compare later....
in the 2 row if the value is less than or equal to the value saved in
the same column in the previus row i want it green, if its greater i
want it red

in either rows if i have a "0" value i just want to paint the cell
plain white

the columns are E to Q but the rows range is not defined, but for a 1
row ill always have a 2 row, and it will start with a 1 row.......

can some one help me there plis??

i can program, but not in VBA, if someone just give me a light where i
can find something that can start me up and i take some ideias i can
program myself, that would do too

the algorith would be something like the following

For each cell in the range(E:Q) do
if cell value = 0 then
paint the cell white
else if cell in the first column is 1 then
paint the cell blue
else if cell in the first column is 2
if cell value is less than or equal to the cell in the previus row and
same column
paint the cell green
else if value is greater than the cell in the previus row and same
column
paint the cell red
next cell

thank you


--
redf1re
------------------------------------------------------------------------
redf1re's Profile: http://www.excelforum.com/member.php...o&userid=31258
View this thread: http://www.excelforum.com/showthread...hreadid=511141


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default comparing and painting cells


thanks... i made some modifications and it works fine

just another question... i need this macro to run after my user run a
query.... i mean, after i pressed that "!" button to run a query,.,....
what macro name does that?


--
redf1re
------------------------------------------------------------------------
redf1re's Profile: http://www.excelforum.com/member.php...o&userid=31258
View this thread: http://www.excelforum.com/showthread...hreadid=511141

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
Painting equal cells Amnon Wilensky Excel Worksheet Functions 2 March 9th 08 01:36 PM
Painting blank cells Amnon Wilensky Excel Worksheet Functions 4 March 8th 08 11:39 PM
Painting Cells MSPLearner Excel Discussion (Misc queries) 1 May 17th 07 08:52 PM
Painting Locked Cells Shrikant Excel Discussion (Misc queries) 3 August 20th 06 06:06 PM
Picture Painting billq Excel Programming 1 June 29th 05 09:26 PM


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