View Full Version : How to find and use the maximum value in VBA
bbuk9999
05-05-2016, 02:56 AM
Hi all,
I am trying to find and use the maximum value in VBA code. The maximum value is used to select a specific cell. Any help is appreciated. Thanks
Good morning bbuk9999,
You could setup a maximum variable and associate the maximum value in a range to that variable for further use.
Something along the lines of this...
Sub GetMaxVal()
Dim lMax As Long
lMax = WorksheetFunction.Max(Range("A:B"))
End Sub
Obviously change the range to suit.
I hope this helps!
bbuk9999
05-05-2016, 04:28 AM
Thanks for your help PAB,
Can you let me know to do this too use the Max value further? Thanks
It depends on what you are trying to do bbuk9999,
If you have a WorkBook, perhaps you could upload it or post a link to it so we can have a look, obviously take out any sensitive information first.
I hope this helps!
bbuk9999
05-05-2016, 06:03 AM
Thanks PAB, please have a look at the attached file. I am trying to find the maximum value in the attached programme in sheet("Container Yard"), ans in the sheet 2 number 1 should be inserted in as shown in the attached file. by the way , the attached file is dynamic table in VBA. Thanks in advance.
bbuk9999
05-13-2016, 02:57 AM
How to choose the first maximum value if we have more than one with the same value? Thanks
Is this for homework or for production? It will make a difference in how I answer.
alihadi
05-13-2016, 05:24 AM
This is for having a knowledge SamT.
Thanks
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.