Finding max value target cell and coloum

fredrerik84

Active Member
Joined
Feb 26, 2017
Messages
383
Hi guys I was lucky enough a few days ago to get help from Marcelo Branco

he helped me find max value at lightning speed with this code:

Sub aTest()
Dim lastRow As Long, vData As Variant, vResult As Variant
Dim i As Long

With Sheets("Sheet1")
lastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
vData = .Range("K12:U" & lastRow)
.Range("W12:Y" & lastRow).ClearContents
vResult = .Range("W12:Y" & lastRow)

For i = LBound(vData, 1) To UBound(vData, 1)
If vData(i, 1) <> "" Or vData(i, 5) <> "" Or vData(i, 9) <> "" Then
vResult(i, 1) = Application.Max(vData(i, 1), vData(i, 5), vData(i, 9))
vResult(i, 2) = Application.Max(vData(i, 2), vData(i, 6), vData(i, 10))
vResult(i, 3) = Application.Max(vData(i, 3), vData(i, 7), vData(i, 11))
End If
Next i
.Range("W12:Y" & lastRow) = vResult
End With
End Sub
Ive been editing this to suit my needs, but the problem im having is to find the target cell for the max value and also the target column for vResult 1-3

I was hoping anyone know a way to handle this ?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,221,418
Messages
6,159,790
Members
451,589
Latest member
Harold14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top