Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VB script to sum up amount


Hi, can anybody help me on this? I've trying to figure out how to sum up
the amount in a column. I've a source file, everytime the data in the
source file can be varied, meaning the amount in the file is not fixed.


By this, how to write a script to sum up all the amount and the total
will be below.

Hope you understand what I am trying to say.

Cheers.


--
tanks1308
------------------------------------------------------------------------
tanks1308's Profile: http://www.excelforum.com/member.php...o&userid=12362
View this thread: http://www.excelforum.com/showthread...hreadid=466016

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VB script to sum up amount

One way:

In a new module, enter this macro, and change Sheet1 to the neam of your
worksheet, and the "A" in "A65536" to the column you need to sum.

Option Explicit

Sub Summit()
Dim lngRow As Long
Dim rngX As Excel.Range

' find the end of the list
Set rngX = Sheet1.Range("A65536").End(xlUp).Offset(1, 0)
lngRow = rngX.Row - 1
rngX.FormulaR1C1 = "=SUM(R[-" & Trim$(CStr(lngRow)) & "]C:R[-1]C)"
End Sub


Alan P.

"tanks1308" wrote
in message ...

Hi, can anybody help me on this? I've trying to figure out how to sum up
the amount in a column. I've a source file, everytime the data in the
source file can be varied, meaning the amount in the file is not fixed.


By this, how to write a script to sum up all the amount and the total
will be below.

Hope you understand what I am trying to say.

Cheers.


--
tanks1308
------------------------------------------------------------------------
tanks1308's Profile:
http://www.excelforum.com/member.php...o&userid=12362
View this thread: http://www.excelforum.com/showthread...hreadid=466016



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VB script to sum up amount

This line:
rngX.FormulaR1C1 = "=SUM(R[-" & Trim$(CStr(lngRow)) & "]C:R[-1]C)"

could be written:
rngX.FormulaR1C1 = "=SUM(R[-" & lngRow & "]C:R[-1]C)"

And maybe just:
rngX.FormulaR1C1 = "=SUM(R1C:R[-1]C)"
to start at row 1 through the row above.


Alan Perkins wrote:

One way:

In a new module, enter this macro, and change Sheet1 to the neam of your
worksheet, and the "A" in "A65536" to the column you need to sum.

Option Explicit

Sub Summit()
Dim lngRow As Long
Dim rngX As Excel.Range

' find the end of the list
Set rngX = Sheet1.Range("A65536").End(xlUp).Offset(1, 0)
lngRow = rngX.Row - 1
rngX.FormulaR1C1 = "=SUM(R[-" & Trim$(CStr(lngRow)) & "]C:R[-1]C)"
End Sub

Alan P.

"tanks1308" wrote
in message ...

Hi, can anybody help me on this? I've trying to figure out how to sum up
the amount in a column. I've a source file, everytime the data in the
source file can be varied, meaning the amount in the file is not fixed.


By this, how to write a script to sum up all the amount and the total
will be below.

Hope you understand what I am trying to say.

Cheers.


--
tanks1308
------------------------------------------------------------------------
tanks1308's Profile:
http://www.excelforum.com/member.php...o&userid=12362
View this thread: http://www.excelforum.com/showthread...hreadid=466016


--

Dave Peterson
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
Calculate the amount of time over a permitted amount (12 hours) Steve M Excel Discussion (Misc queries) 9 June 2nd 10 09:25 PM
How to change amount in figure to amount in words? Lotis Excel Worksheet Functions 3 June 27th 07 04:34 AM
Formula for amount owing subtract amount paid Taperchart Excel Worksheet Functions 1 June 4th 06 05:51 PM
How can I calculate amount of time left based on amount spent? KLD Excel Worksheet Functions 3 May 23rd 06 04:20 PM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM


All times are GMT +1. The time now is 07:29 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"