Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding current selection


I am not even sure that this can be done and I have no idea where t
start on this one.
Basically, I need a macro to add up the user selected cells and displa
the result in the last row left one.
for example.
user selects cells C3:C10
the result needs to be displayed in B10

The user then selects C11:C32
the results need to be displayed in B32

The user can select any number of cells within colum C and the cell ro
can be anything.

Is there code which would allow this to happen using a button to star
the macro after the highlighting of the cells?

Thanks in advance

--
RICOU
-----------------------------------------------------------------------
RICOUK's Profile: http://www.excelforum.com/member.php...fo&userid=1879
View this thread: http://www.excelforum.com/showthread.php?threadid=39974

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Adding current selection

Sub Sum_Selected2()

Dim Rng As Range, rng1 As Range
Set Rng = Selection
Set rng1 = Rng.Areas(Rng.Areas.Count)
Set rng1 = rng1(rng1.Rows.Count, rng1.Columns.Count)
rng1.Offset(0, -1).Formula = "=Sum(" & Rng.Address & ")"

End Sub


Gord Dibben Excel MVP

On Sat, 27 Aug 2005 12:10:37 -0500, RICOUK
wrote:


I am not even sure that this can be done and I have no idea where to
start on this one.
Basically, I need a macro to add up the user selected cells and display
the result in the last row left one.
for example.
user selects cells C3:C10
the result needs to be displayed in B10

The user then selects C11:C32
the results need to be displayed in B32

The user can select any number of cells within colum C and the cell row
can be anything.

Is there code which would allow this to happen using a button to start
the macro after the highlighting of the cells?

Thanks in advance.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Adding current selection

One way:

Public Sub Button1_Click()
With Selection
.Item(.Count).Offset(0, -1).Value = _
Application.Sum(.Cells)
End With
End Sub

Note that there's no error checking

In article ,
RICOUK wrote:

I am not even sure that this can be done and I have no idea where to
start on this one.
Basically, I need a macro to add up the user selected cells and display
the result in the last row left one.
for example.
user selects cells C3:C10
the result needs to be displayed in B10

The user then selects C11:C32
the results need to be displayed in B32

The user can select any number of cells within colum C and the cell row
can be anything.

Is there code which would allow this to happen using a button to start
the macro after the highlighting of the cells?

Thanks in advance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding current selection


Thanks for that, my project is nearly complete, now I have just got t
tidy up everything

--
RICOU
-----------------------------------------------------------------------
RICOUK's Profile: http://www.excelforum.com/member.php...fo&userid=1879
View this thread: http://www.excelforum.com/showthread.php?threadid=39974

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
excel change default column sort to current selection john palmer Excel Worksheet Functions 2 March 8th 05 03:07 PM
Capture Current Selection in a Combo Box Randy[_10_] Excel Programming 3 August 6th 04 09:43 PM
Update on Current Selection Randal W. Hozeski Excel Programming 0 December 29th 03 04:37 PM
Calculated value based on current line selection Bruce Roberson Excel Programming 0 August 20th 03 07:51 PM


All times are GMT +1. The time now is 01:14 AM.

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"