Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Sub Main()
  2.      Dim Values() As Integer
  3.       Range("A1").Select
  4.       Do Until ActiveCell.Value = 0
  5.          ReDim Preserve Values(1 To UBound(Values) + 1) As Integer
  6.          Values(UBound(Values)) = ActiveCell.Value
  7.          ActiveCell.Offset(1, 0).Select
  8.       Loop
  9.       Max = WorksheetFunction.Max(Values())
  10.       MsgBox (Max)
  11.       Count = 0
  12.       For Each num In Values()
  13.         If num = 5 Then Count = Count + 1
  14.       Next
  15.       MsgBox "Max: " & Max & vbCrLf & "5 Occurances: " & Count
  16. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement