Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 64
Default Sum Selection

Any vba expert can help in making this macro work on at two sheets in a
workbook or 2 workbooks - I would like to place the result in a
diffrent sheet & it shows the proper link.Thxs

Dim UserRange As Range

Output = "=sum(" & Selection.Address(External:=False,
RowAbsolute:=False, ColumnAbsolute:=False) & ")"
Prompt = "Select a cell for the output."
Title = "Select a cell"


On Error Resume Next
Set UserRange = Application.InputBox( _
Prompt:=Prompt, _
Title:=Title, _
Default:=ActiveCell.Address, _
Type:=8) 'Range selection

If UserRange Is Nothing Then
MsgBox "Canceled."
Else
UserRange.Range("A1") = Output
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sum Selection

change
External:=False
to
External:=True

--
Regards,
Tom Ogilvy

"al" wrote in message
ups.com...
Any vba expert can help in making this macro work on at two sheets in a
workbook or 2 workbooks - I would like to place the result in a
diffrent sheet & it shows the proper link.Thxs

Dim UserRange As Range

Output = "=sum(" & Selection.Address(External:=False,
RowAbsolute:=False, ColumnAbsolute:=False) & ")"
Prompt = "Select a cell for the output."
Title = "Select a cell"


On Error Resume Next
Set UserRange = Application.InputBox( _
Prompt:=Prompt, _
Title:=Title, _
Default:=ActiveCell.Address, _
Type:=8) 'Range selection

If UserRange Is Nothing Then
MsgBox "Canceled."
Else
UserRange.Range("A1") = Output
End If
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 64
Default Sum Selection

Tom
Thxs a lot for your reply !!!
But it does not work properly for non contiguous cells (i.e when I
press control & select cell from different location)
Can you pls improve my macro.Thxs beforehand - I'm nearly there
PLS PLS HELP
THXS




Tom Ogilvy wrote:
change
External:=False
to
External:=True

--
Regards,
Tom Ogilvy

"al" wrote in message
ups.com...
Any vba expert can help in making this macro work on at two sheets in a
workbook or 2 workbooks - I would like to place the result in a
diffrent sheet & it shows the proper link.Thxs

Dim UserRange As Range

Output = "=sum(" & Selection.Address(External:=False,
RowAbsolute:=False, ColumnAbsolute:=False) & ")"
Prompt = "Select a cell for the output."
Title = "Select a cell"


On Error Resume Next
Set UserRange = Application.InputBox( _
Prompt:=Prompt, _
Title:=Title, _
Default:=ActiveCell.Address, _
Type:=8) 'Range selection

If UserRange Is Nothing Then
MsgBox "Canceled."
Else
UserRange.Range("A1") = Output
End If
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sum Selection

Try this: (assume you will be working within the same workbook)

Sub CCC()
Dim UserRange As Range
Dim output as String, Prompt as String
Dim Title as String, sName as String
output = Selection.Address( _
External:=False, RowAbsolute:=False, _
ColumnAbsolute:=False) & ")"
Prompt = "Select a cell for the output."
Title = "Select a cell"
sname = "'" & ActiveSheet.Name & "'!"
output = Replace(output, ",", "," & sname)
output = "=sum(" & sname & output
On Error Resume Next
Set UserRange = Application.InputBox( _
Prompt:=Prompt, _
Title:=Title, _
Default:=ActiveCell.Address, _
Type:=8) 'Range selection

If UserRange Is Nothing Then
MsgBox "Canceled."
Else
UserRange.Range("A1") = output
End If
End Sub

--
Regards,
Tom Ogilvy


"al" wrote in message
oups.com...
Tom
Thxs a lot for your reply !!!
But it does not work properly for non contiguous cells (i.e when I
press control & select cell from different location)
Can you pls improve my macro.Thxs beforehand - I'm nearly there
PLS PLS HELP
THXS




Tom Ogilvy wrote:
change
External:=False
to
External:=True

--
Regards,
Tom Ogilvy

"al" wrote in message
ups.com...
Any vba expert can help in making this macro work on at two sheets in

a
workbook or 2 workbooks - I would like to place the result in a
diffrent sheet & it shows the proper link.Thxs

Dim UserRange As Range

Output = "=sum(" & Selection.Address(External:=False,
RowAbsolute:=False, ColumnAbsolute:=False) & ")"
Prompt = "Select a cell for the output."
Title = "Select a cell"


On Error Resume Next
Set UserRange = Application.InputBox( _
Prompt:=Prompt, _
Title:=Title, _
Default:=ActiveCell.Address, _
Type:=8) 'Range selection

If UserRange Is Nothing Then
MsgBox "Canceled."
Else
UserRange.Range("A1") = Output
End If
End Sub




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum Selection

THXS A LOT ! IT WORKS ON SAME WORKBOOK (Won't ask you to make it work
on different workbooks as you've already done a lot !)
Pls keep on supporting us !!!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Limiting selection in a cell AND linking that selection to a list Lisa Excel Discussion (Misc queries) 1 July 28th 09 05:00 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Identifying a selection of a selection of a range swimfast Excel Worksheet Functions 1 March 1st 07 02:51 AM
Object Type of a selection... counting rows in a selection Acid-Sky[_2_] Excel Programming 3 August 23rd 05 09:53 AM
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. jonH Excel Programming 3 June 7th 04 09:13 PM


All times are GMT +1. The time now is 04:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"