ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get the max number from a collection (https://www.excelbanter.com/excel-programming/376957-get-max-number-collection.html)

[email protected]

Get the max number from a collection
 
Hi Fellows

How can I get the Max number from a collection thata has only numbers

Thanks
GC


RB Smissaert

Get the max number from a collection
 
I think you will just have to loop through all the items.

RBS

wrote in message
ups.com...
Hi Fellows

How can I get the Max number from a collection thata has only numbers

Thanks
GC



Don Guillett

Get the max number from a collection
 
Sub getmax()
MsgBox Application.Max(Columns("d"))
End Sub
--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Hi Fellows

How can I get the Max number from a collection thata has only numbers

Thanks
GC




Norman Jones

Get the max number from a collection
 
Hi Don,

What relationship has Columns("d") with the OP's collection?



---
Regards,
Norman



"Don Guillett" wrote in message
...
Sub getmax()
MsgBox Application.Max(Columns("d"))
End Sub
--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Hi Fellows

How can I get the Max number from a collection thata has only numbers

Thanks
GC






[email protected]

Get the max number from a collection
 

Ok thanks, If I loop thru the collection how can I get the max?

On Nov 7, 5:02 pm, "Norman Jones"
wrote:
Hi Don,

What relationship has Columns("d") with the OP's collection?

---
Regards,
Norman

"Don Guillett" wrote in l...



Sub getmax()
MsgBox Application.Max(Columns("d"))
End Sub
--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Hi Fellows


How can I get the Max number from a collection thata has only numbers


Thanks
GC- Hide quoted text -- Show quoted text -



Tom Ogilvy

Get the max number from a collection
 
One approach:

Sub EFG()
Dim col As Collection
Dim i As Long, ii As Long
Dim lmax As Long
Dim itm As Variant
Set col = New Collection
For i = 1 To 30
ii = Int(Rnd() * 100 + 1)
On Error Resume Next
col.Add ii, CStr(ii)
On Error GoTo 0
Next
For Each itm In col
If itm lmax Then
lmax = itm
End If
Next
MsgBox "Max value is: " & lmax
End Sub

--
Regards,
Tom Ogilvy


wrote in message
oups.com...

Ok thanks, If I loop thru the collection how can I get the max?

On Nov 7, 5:02 pm, "Norman Jones"
wrote:
Hi Don,

What relationship has Columns("d") with the OP's collection?

---
Regards,
Norman

"Don Guillett" wrote in
l...



Sub getmax()
MsgBox Application.Max(Columns("d"))
End Sub
--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Hi Fellows


How can I get the Max number from a collection thata has only numbers


Thanks
GC- Hide quoted text -- Show quoted text -





[email protected]

Get the max number from a collection
 
I find this way to do it

iva=col(1)

For i = 1 To col.Count
On Error GoTo Fin
If ival col(i + 1) Then
ival = col(i + 1)
End If
Next i

wrote:
Hi Fellows

How can I get the Max number from a collection thata has only numbers

Thanks
GC




All times are GMT +1. The time now is 01:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com