Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to find a max value in an dictionary in Power Point Application?

The following code works properly in Excel.

But I am looking for Power Point solution.

How to find a max value in an dictionary in Power Point Application?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    Sub Macro1()
    
        Dim dict As Object
        Set dict = CreateObject("Scripting.Dictionary")
        
        For i = 1 To 10
            dict.Add Key:=i, Item:=i
        Next i
        
        For i = 0 To dict.Count - 1
           Debug.Print dict.Keys()(i), dict.Items()(i)
        Next i
        
        'The following two lines works properly in Excel. 
        'But I am looking for Power Point solution.
        Debug.Print Application.Max(dict.Items)
        Debug.Print WorksheetFunction.Max(dict.Items)
    
    End Sub

>Solution :

This will work in Powerpoint:

Sub Macro1()
    
        Dim dict As Object
        Set dict = CreateObject("Scripting.Dictionary")
        
        Dim i As Long
        For i = 1 To 10
            dict.Add Key:=i, Item:=i
        Next i
        
        Dim iMax As Long
        For i = 0 To dict.Count - 1
           Debug.Print dict.Keys()(i), dict.Items()(i)
           If dict.Items()(i) > iMax Then iMax = dict.Items()(i)
        Next i
        
        Debug.Print iMax
    End Sub

You have to check for the max value within a loop.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading