Storing Max values from worksheet to an array

mandukes

Forum Rules
Joined
May 25, 2013
Messages
90
Hi, I have data arranged in a sheet like the following order. (https://www.dropbox.com/s/ynqjaxuzo6qucau/MDia.xlsx?dl=0)

I need to find the Max Values in columns and store them in an array - OPDia(IL,IL)
Note: IL is the total Rows/Columns. (from 1 to 33)

thanks:)

4a2bb134bb25649737f458a878e351f0.png
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Not clear what you want to do with the array after it's populated and link doesn't work, try:
Code:
Sub MaxToArray()

    Dim y           As Long
    Dim arr()       As Variant
        
    arr = Cells(36, 3).Resize(, 33).Value
    
    For y = 3 To 35
        arr(1, y - 2) = Application.Max(Cells(3, y).Resize(33))
    Next y
    
    Cells(37, 3).Resize(UBound(arr, 1), UBound(arr, 2)).Value = arr
    
    Erase arr

End Sub
 
Last edited:
Upvote 0
Thanks for the CODE it worked like charm :)
I only wanted the MAX data to be stored separately in an array for further calculations , which I figured out.

Code:
[TABLE="width: 777"]
<tbody>[TR]
  [TD="width: 28, align: right"]95[/TD]
  [TD="width: 28, align: right"]83[/TD]
  [TD="width: 21, align: right"]84[/TD]
  [TD="width: 28, align: right"]79[/TD]
  [TD="width: 21, align: right"]84[/TD]
  [TD="width: 28, align: right"]90[/TD]
  [TD="width: 28, align: right"]13[/TD]
  [TD="width: 28, align: right"]13[/TD]
  [TD="width: 21, align: right"]75[/TD]
  [TD="width: 21, align: right"]52[/TD]
  [TD="width: 21, align: right"]55[/TD]
  [TD="width: 21, align: right"]92[/TD]
  [TD="width: 28, align: right"]34[/TD]
  [TD="width: 28, align: right"]79[/TD]
  [TD="width: 21, align: right"]47[/TD]
  [TD="width: 21, align: right"]60[/TD]
  [TD="width: 21, align: right"]66[/TD]
  [TD="width: 21, align: right"]53[/TD]
  [TD="width: 21, align: right"]36[/TD]
  [TD="width: 21, align: right"]64[/TD]
  [TD="width: 21, align: right"]32[/TD]
  [TD="width: 28, align: right"]69[/TD]
  [TD="width: 28, align: right"]65[/TD]
  [TD="width: 28, align: right"]75[/TD]
  [TD="width: 28, align: right"]98[/TD]
  [TD="width: 21, align: right"]36[/TD]
  [TD="width: 21, align: right"]74[/TD]
  [TD="width: 21, align: right"]49[/TD]
  [TD="width: 21, align: right"]74[/TD]
  [TD="width: 21, align: right"]62[/TD]
  [TD="width: 21, align: right"]45[/TD]
  [TD="width: 21, align: right"]42[/TD]
  [TD="width: 21, align: right"]45[/TD]
[/TR]
</tbody>[/TABLE]

Regards
~M



Not clear what you want to do with the array after it's populated and link doesn't work, try:
Code:
Sub MaxToArray()

    Dim y           As Long
    Dim arr()       As Variant
        
    arr = Cells(36, 3).Resize(, 33).Value
    
    For y = 3 To 35
        arr(1, y - 2) = Application.Max(Cells(3, y).Resize(33))
    Next y
    
    Cells(37, 3).Resize(UBound(arr, 1), UBound(arr, 2)).Value = arr
    
    Erase arr

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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