Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How tochange color of MINIF cell ?


Hi!
I have one table, and need some vba which will find the min value (but
value <0) in each row of table and change interior color of this cells.

-
Thanks a lot,
MM


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How tochange color of MINIF cell ?

You could do this with conditional formatting and skip the code.

for code

dim mMin as double, rng as Range
Dim cell as Range
for each rw in Range("Table").Rows
mMin = -10
set rng = Nothing
for each cell in rw.cells
if isnumeric(cell) then
if cell.Value mMin and cell.Value < 0 then
set rng = cell
mMin = cell.value
end if
End if
Next
if not rng is nothing then
rng.Interior.ColorIndex = 6
end if
Next

--
Regards,
Tom Ogilvy

"Mima" wrote in message
...

Hi!
I have one table, and need some vba which will find the min value (but
value <0) in each row of table and change interior color of this cells.

-
Thanks a lot,
MM




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How tochange color of MINIF cell ?

Thx you Tom. Your code find me maximum value (I need minimum).

--
Regards, MM


"Tom Ogilvy" wrote in message
...
You could do this with conditional formatting and skip the code.

for code

dim mMin as double, rng as Range
Dim cell as Range
for each rw in Range("Table").Rows
mMin = -10
set rng = Nothing
for each cell in rw.cells
if isnumeric(cell) then
if cell.Value mMin and cell.Value < 0 then
set rng = cell
mMin = cell.value
end if
End if
Next
if not rng is nothing then
rng.Interior.ColorIndex = 6
end if
Next

--
Regards,
Tom Ogilvy

"Mima" wrote in message
...

Hi!
I have one table, and need some vba which will find the min value (but
value <0) in each row of table and change interior color of this cells.

-
Thanks a lot,
MM






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How tochange color of MINIF cell ?

Whoops:

dim mMin as double, rng as Range
Dim cell as Range
Range("Table").Interior.colorIndex = xlNone
for each rw in Range("Table").Rows
mMin = Application.Max(rw)
set rng = Nothing
for each cell in rw.cells
if isnumeric(cell) then
if cell.Value < mMin and cell.Value < 0 then
set rng = cell
mMin = cell.value
end if
End if
Next
if not rng is nothing then
rng.Interior.ColorIndex = 6
end if
Next

--
Regards,
Tom Ogilvy

"Mima" wrote in message
...
Thx you Tom. Your code find me maximum value (I need minimum).

--
Regards, MM


"Tom Ogilvy" wrote in message
...
You could do this with conditional formatting and skip the code.

for code

dim mMin as double, rng as Range
Dim cell as Range
for each rw in Range("Table").Rows
mMin = -10
set rng = Nothing
for each cell in rw.cells
if isnumeric(cell) then
if cell.Value mMin and cell.Value < 0 then
set rng = cell
mMin = cell.value
end if
End if
Next
if not rng is nothing then
rng.Interior.ColorIndex = 6
end if
Next

--
Regards,
Tom Ogilvy

"Mima" wrote in message
...

Hi!
I have one table, and need some vba which will find the min value (but
value <0) in each row of table and change interior color of this

cells.

-
Thanks a lot,
MM








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How tochange color of MINIF cell ?


Tom,

Your code delivers MAXIMUM values in each row as tested against th
following sample data in a1:d4

A B C D
-5 3 -1 15
10 7 -4 -3
15 -9 5 -8
-8 -9 10 2

Sub mm()
Dim mMin As Double, rng As Range
Dim cell As Range
For Each rw In Range("a1:d4").Rows
mMin = -10
Set rng = Nothing
For Each cell In rw.Cells
If IsNumeric(cell) Then
If cell.Value mMin And cell.Value < 0 Then
Set rng = cell
MsgBox rng.Address
mMin = cell.Value
End If
End If
Next
If Not rng Is Nothing Then
rng.Interior.ColorIndex = 6
End If
Next


Davi

--
david
-----------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...fo&userid=2064
View this thread: http://www.excelforum.com/showthread.php?threadid=48483



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How tochange color of MINIF cell ?

thanks for the heads up.
See corrected post in another leg of this thread.

--
Regards,
Tom Ogilvy


"davidm" wrote in
message ...

Tom,

Your code delivers MAXIMUM values in each row as tested against the
following sample data in a1:d4

A B C D
-5 3 -1 15
10 7 -4 -3
15 -9 5 -8
-8 -9 10 2

Sub mm()
Dim mMin As Double, rng As Range
Dim cell As Range
For Each rw In Range("a1:d4").Rows
mMin = -10
Set rng = Nothing
For Each cell In rw.Cells
If IsNumeric(cell) Then
If cell.Value mMin And cell.Value < 0 Then
Set rng = cell
MsgBox rng.Address
mMin = cell.Value
End If
End If
Next
If Not rng Is Nothing Then
rng.Interior.ColorIndex = 6
End If
Next


David


--
davidm
------------------------------------------------------------------------
davidm's Profile:

http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=484834



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
How toChange color of first letter inEach word ofA column at once LSSK Excel Discussion (Misc queries) 1 February 7th 10 03:14 PM
Is there any funcion like a @maxif or @minif? Just Anna Excel Worksheet Functions 7 September 29th 08 06:37 PM
minif Andes2U Excel Worksheet Functions 5 November 5th 07 02:43 PM
MINIF ???? Jock Excel Worksheet Functions 4 June 21st 07 12:34 PM
Minif / Maxif ? Thrain Excel Worksheet Functions 3 December 1st 05 10:14 AM


All times are GMT +1. The time now is 04:52 AM.

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

About Us

"It's about Microsoft Excel"