# How to use a macro to determine which number is the highest?

Hi,

can you help me with my presentation? I need a macro that finds the highest number (or numbers) in the labels 1 to 4 and write it to me along with a letter (which belongs to a number) into the blue rectangle in the form "number: 51, letter: A"
If several numbers are the same (they can also change) should be a blue rectangle for example write: "numbers: 51, 51, letters: A, D
Numbers, like letters - the fourth most
Look for attachment - to illustrate, I think it will be easier to understand.

Regards,

TM TEST.ppt
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try the following:

Chris
Sub biggie()
Dim nums(1 To 4) As Integer
Dim arrNumbers() As String
Dim arrAlpha() As String
Dim intmax As Integer
Dim strMax As String
Dim intCycle As Integer
Dim intArraySize As Integer

For intCycle = 1 To 4
nums(intCycle) = CInt(Application.ActivePresentation.Slides(1).Shapes("Label" & intCycle).OLEFormat.Object.Caption)
If nums(intCycle) > intmax Then intmax = nums(intCycle)
Next
For intCycle = 1 To 4
If nums(intCycle) = intmax Then
ReDim Preserve arrNumbers(0 To intArraySize)
ReDim Preserve arrAlpha(0 To intArraySize)
arrNumbers(intArraySize) = intmax
arrAlpha(intArraySize) = Chr(Asc("A") + intCycle - 1)
intArraySize = intArraySize + 1
End If
Next
Application.ActivePresentation.Slides(1).Shapes("the_highest_number").TextFrame.TextRange.Text = "Numbers: " & Join(arrNumbers, ", ") & ", " & "Letters: " & Join(arrAlpha, ", ")
End Sub
TEST-3.ppt
0
If there is a chance of the letters being modified then you could replace:

arrAlpha(intArraySize) = Chr(Asc("A") + intCycle - 1)
with
arrAlpha(intArraySize) = Application.ActivePresentation.Slides(1).Shapes(Chr(Asc("A") + intCycle - 1)).TextFrame.TextRange.Text

In the supplied code

Chris
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
@Chris
Macro works perfectly fine, exactly as I needed!
Thank you.

Regards,

TM
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.