+ Reply to Thread
Results 1 to 4 of 4

Sum Range

Hybrid View

  1. #1
    Registered User
    Join Date
    11-19-2006
    Posts
    15

    Sum Range

    Hello everyone, I'm new to the fourm and need your help.
    I'm trying to sum a range by using an inputbox then displaying the results in a message box.
    My problem is that the inputbox returns True instead of the range, I don't really know how to pass the range to the Sum function so I tried what I have written, Can anyone help?

    here is the code:

    Sub MyRange()
    'On Error GoTo Quit
    Dim RngA As Range
    Dim myAnswer As Variant

    Set RngA = Application.InputBox(prompt:="Entrer the range of cels", Type:=8)
    RngA.Activate
    MsgBox RngA.Select
    myAnswer = Application.Sum(RngA.Select)
    MsgBox ("Total hours = " & myAnswer)
    'Quit:
    End Sub

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    just a tiny correction
    Sub MyRange()
    'On Error GoTo Quit
    Dim RngA As Range
    Dim myAnswer As Variant
    
    Set RngA = Application.InputBox(prompt:="Enter the range of cells", Type:=8)
    myAnswer = Application.Sum(RngA)
    MsgBox ("Total hours = " & myAnswer)
    'Quit:
    End Sub
    HTH
    Carim

  3. #3
    Registered User
    Join Date
    11-19-2006
    Posts
    15

    Smile Thank you

    Carim, thanks for the reply that took care of it, it also might have helped if I can spell cells (cels) correctly.

    Thanks again and have a great holiday.

    Garf

  4. #4
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Glad your problem is fixed.

    Thanks for the feedback

    Carim

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1