View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Inputbox() Sum() MsgBox()

Just a couple of thoughts,

Declare AreaSum as Double not Long for decimals

Wrap the SUM in error handling, in case

On Error Resume Next
AreaSum = WorksheetFunction.Sum(AreaClick)
On Error GoTo 0
If Err.Number < 0 Then
Msgbox "Problem with range"
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Nigel" wrote in message
...
Try this modification........

Sub DumbAss_Click()
Dim AreaClick As Range
Dim AreaSum As Long
Windows("how spent 73104rev").Activate
Sheets("ITA").Select
Set AreaClick = Application.InputBox(prompt:="Please click on area to

sum",
Title:="Auto Sum", Type:=8)
AreaSum = WorksheetFunction.Sum(AreaClick)
MsgBox (AreaSum)
End Sub

Cheers
Nigel

"Dim DumbAss as Name" <Dim DumbAss as

wrote
in message ...
Can anyone help me? I am simply trying to have a range inputbox and then

have
the sum of that range pop up in a message box.

This is what I have. Do I need a (for each cell in range statement)? If

so
how do I set that up? Any help thanks in advance.

Private Sub DumbAss_Click()
Dim AreaClick As Range
Dim AreaSum As String
Windows("how spent 73104rev").Activate
Sheets("ITA ").Select
Set AreaClick = Application.InputBox(prompt:="Please click on area to

sum",
Title:="Auto Sum", Type:=8)
Set AreaSum = WorksheetFunction.Sum(AreaClick)
MsgBox (AreaSum)
End Sub