Results 1 to 4 of 4

Thread: asking user to enter 10 numbers then find the max

  1. #1
    Board Regular
    Join Date
    Mar 2016
    Posts
    1,398
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default asking user to enter 10 numbers then find the max

    Hi

    I want to write a code (for learning purpose) asking user to enter 10 numbers or whatever user going to enter then the code will find the max number from these number and print a message saying "number ?? is the max you entered".

    Can that be done in VBA?

    Thank you very much.

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,369
    Post Thanks / Like
    Mentioned
    471 Post(s)
    Tagged
    47 Thread(s)

    Default Re: asking user to enter 10 numbers then find the max

    Maybe
    Code:
    Sub lezawang()
       Dim Ary As Variant, Res As Variant
       Dim i As Long
       
       Res = InputBox("please enter 10 numbers like 1,7,5,9")
       If Res <> "" Then
          Res = Split(Res, ",")
          ReDim Ary(UBound(Res))
          For i = 0 To UBound(Res)
             Ary(i) = Res(i) * 1
          Next i
          MsgBox Application.Max(Ary)
       End If
    End Sub
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    Board Regular
    Join Date
    Mar 2016
    Posts
    1,398
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: asking user to enter 10 numbers then find the max

    Works very nicely. Thank you very much. I appreciate it

  4. #4
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,369
    Post Thanks / Like
    Mentioned
    471 Post(s)
    Tagged
    47 Thread(s)

    Default Re: asking user to enter 10 numbers then find the max

    You're welcome & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •