Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Paint a cell ?

Hi all!

I've got a problem and ask for help.

I need some macro that will highlight (paint) a cell in each row where is
the highest value in this row.

Thanks !




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Paint a cell ?

Maybe

Dim oRow As Range
Dim iCol As Long

For Each oRow In Selection.Rows
If Application.Count(oRow) 0 Then
iCol = Application.Match(Application.Max(oRow), oRow, 0)
Cells(oRow.Row, iCol).Interior.Color = vbRed
End If
Next oRow


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Skic" wrote in message ...
Hi all!

I've got a problem and ask for help.

I need some macro that will highlight (paint) a cell in each row where is
the highest value in this row.

Thanks !






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Paint a cell ?

When I tried the below, I originally got some strange results. After a
little debugging I tried moving my selection so that it started in Column A
and then everything worked as expected. What change would be necessary to
make this work if the selection range started elsewhere, say in column c?

"Bob Phillips" wrote:

Maybe

Dim oRow As Range
Dim iCol As Long

For Each oRow In Selection.Rows
If Application.Count(oRow) 0 Then
iCol = Application.Match(Application.Max(oRow), oRow, 0)
Cells(oRow.Row, iCol).Interior.Color = vbRed
End If
Next oRow


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Skic" wrote in message ...
Hi all!

I've got a problem and ask for help.

I need some macro that will highlight (paint) a cell in each row where is
the highest value in this row.

Thanks !







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Paint a cell ?

This appears to work for me:
Cells(oRow.Row, iCol + Selection.Column - 1).Interior.Color = vbRed

"Kleev" wrote:

When I tried the below, I originally got some strange results. After a
little debugging I tried moving my selection so that it started in Column A
and then everything worked as expected. What change would be necessary to
make this work if the selection range started elsewhere, say in column c?

"Bob Phillips" wrote:

Maybe

Dim oRow As Range
Dim iCol As Long

For Each oRow In Selection.Rows
If Application.Count(oRow) 0 Then
iCol = Application.Match(Application.Max(oRow), oRow, 0)
Cells(oRow.Row, iCol).Interior.Color = vbRed
End If
Next oRow


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Skic" wrote in message ...
Hi all!

I've got a problem and ask for help.

I need some macro that will highlight (paint) a cell in each row where is
the highest value in this row.

Thanks !







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Paint a cell ?

If you know your range, I would use

Dim oRow As Range
Dim iCol As Long

For Each oRow In Columns(3).Rows
If Application.Count(oRow) 0 Then
iCol = Application.Match(Application.Max(oRow), oRow, 0)
Cells(oRow.Row, iCol).Interior.Color = vbRed
End If
Next oRow


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Kleev" wrote in message
...
This appears to work for me:
Cells(oRow.Row, iCol + Selection.Column - 1).Interior.Color = vbRed

"Kleev" wrote:

When I tried the below, I originally got some strange results. After a
little debugging I tried moving my selection so that it started in

Column A
and then everything worked as expected. What change would be necessary

to
make this work if the selection range started elsewhere, say in column

c?

"Bob Phillips" wrote:

Maybe

Dim oRow As Range
Dim iCol As Long

For Each oRow In Selection.Rows
If Application.Count(oRow) 0 Then
iCol = Application.Match(Application.Max(oRow), oRow, 0)
Cells(oRow.Row, iCol).Interior.Color = vbRed
End If
Next oRow


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Skic" wrote in message

...
Hi all!

I've got a problem and ask for help.

I need some macro that will highlight (paint) a cell in each row

where is
the highest value in this row.

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
How do I copy a picture from Paint to a specific cell in Excel? tgw4 Excel Discussion (Misc queries) 1 March 22nd 08 02:52 AM
Need conditional statement to paint a cell Jim Thomlinson Excel Discussion (Misc queries) 0 May 31st 06 03:44 PM
Need conditional statement to paint a cell Jim Thomlinson Excel Worksheet Functions 0 May 31st 06 03:44 PM
can you tell me how to embed a pic for paint into an excel cell Duncan Excel Worksheet Functions 0 April 26th 06 01:14 AM
Use VBA to format paint cell(s) [email protected] Excel Programming 3 October 12th 05 07:13 PM


All times are GMT +1. The time now is 01:16 AM.

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"