Use Variable Names in Large Function (VBA)

SidKol

New Member
Joined
Oct 14, 2015
Messages
47
Dim Value1 As Double
Dim Value2 As Double
Dim Value3 As Double

'Example values
Value1 = 1
Value2 = 2
Value3 = 3


How can i get the Largest value using the names of the variables?

So something like:

= Application.Large((Value1, Value2, Value,3), 1)
 
Last edited:

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,416
Office Version
  1. 365
Platform
  1. Windows
How about
Code:
MsgBox Application.Large(Array(Value1, Value2, Value3), 1)
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,319
Office Version
  1. 2010
Platform
  1. Windows
Alternately, instead of individual variables that you have to bundle up into an Array function, you could use an actual array and pass that directly...
Code:
Sub Test()
  Dim Value(1 To 3) As Long
  Value(1) = 1
  Value(2) = 2
  Value(3) = 3
  MsgBox Application.Large(Value, 1)
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,109,146
Messages
5,527,076
Members
409,743
Latest member
sukuto20

This Week's Hot Topics

Top