Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Sum column values and insert result in last cell with VBA

Hi all, This is probably so simple but it is eluding me...

Column "AL" has a variable number of values in it and i need to get the
total and paste only the total in the cell below the last used cell.

Could somebody please help me out of my misery... :-0)

Thnks in advance

--
Les
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Sum column values and insert result in last cell with VBA

On May 22, 1:39 pm, Les wrote:
Hi all, This is probably so simple but it is eluding me...

Column "AL" has a variable number of values in it and i need to get the
total and paste only the total in the cell below the last used cell.

Could somebody please help me out of my misery... :-0)

Thnks in advance

--
Les


Here is one way I can think of ...

Sub SumColumn()
Dim sCol, sRow
Range("AL1").EntireColumn.Cells(65536, 1).Select
ActiveCell.End(xlUp).Select
sCol = Split(ActiveCell.Address, "$")(1)
sRow = ActiveCell.Row
' Creates a formula that sums column from row 1 to last occupied
cell
ActiveCell.Cells(2, 1) = "=SUM(" & sCol & "1:" & sCol & sRow & ")"
' Optional - converts cell from formula to its result
' ActiveCell.Cells(2, 1) = ActiveCell.Cells(2, 1)
End Sub

This acts on currently active worksheet and fails if the active object
is not a worksheet (such as a chartsheet).

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Sum column values and insert result in last cell with VBA

Try

With ActiveSheet.Cells(Rows.Count, "AL").End(xlUp)(2, 1)
.Formula = "=SUM(AL1:" & .Offset(-1, 0).Address & ")"
End With


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"Les" wrote in message
...
Hi all, This is probably so simple but it is eluding me...

Column "AL" has a variable number of values in it and i need to get the
total and paste only the total in the cell below the last used cell.

Could somebody please help me out of my misery... :-0)

Thnks in advance

--
Les


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
How calculate a difference btwn 2 TextBox and insert the result inthe appropriate cell John[_34_] Excel Discussion (Misc queries) 4 November 20th 11 02:54 PM
insert column header in cell below result of max FUNCTION mark s Excel Worksheet Functions 2 July 13th 08 03:36 AM
How to insert line of text on other worksheet depending upon result in a cell? Pheasant Plucker® Excel Discussion (Misc queries) 3 March 20th 06 03:05 PM
How to insert line on other worksheet depending upon result in cell? Pheasant Plucker® Excel Discussion (Misc queries) 4 March 17th 06 09:05 AM
Macro to insert formula result into range with zero values in cell JPS Excel Programming 9 July 6th 05 05:56 AM


All times are GMT +1. The time now is 03:02 AM.

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

About Us

"It's about Microsoft Excel"