ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Paint a cell ? (https://www.excelbanter.com/excel-programming/344107-paint-cell.html)

Skic

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 !





Bob Phillips[_6_]

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 !







Kleev

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 !








Kleev

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 !








Bob Phillips[_6_]

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 !











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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com