max & min of a:a ect........

jdavis9

Active Member
Joined
Mar 8, 2002
Messages
337
How do i return the max and min values of a column to vb?

the equiv of =max(a:a) or =min(a:a)

Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Try the following, change the MsgBox bit to YourVariable = ... etc: -
<pre>
MsgBox Application.WorksheetFunction.Max(Range("A:A"))
MsgBox Application.WorksheetFunction.Min(Range("A:A"))
</pre>
 
Upvote 0
Hi,

You can use Excel's WorksheetFunction object to use many worksheet functions in your VBA code. For example:-

Code:
Sub GetMaxAndMinValues()
Dim vMax, vMin

vMax = WorksheetFunction.Max(Range("A:A"))
vMin = WorksheetFunction.Min(Range("B:B"))

MsgBox "Maximum value in column A = " & vMax & vbCrLf & _
        "Minimum value in column B = " & vMin, vbInformation, "Max and Min"

End Sub

To see a comprehensive list of worksheet functions which work in VBA see List Of Worksheet Functions Available to Visual Basic,
 
Upvote 0

Forum statistics

Threads
1,213,501
Messages
6,114,010
Members
448,543
Latest member
MartinLarkin

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