Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Add Total to End of columns

Hi there, my query is very complicated and hope someone can help me!!!

I have created 2 tabs, one is for data entry (Man days entry) and the second
one is for calculations (Rate * Days) and variance calculations. For the
calculation tab, i have created a macro and so far it is working fine.
Basically it says if there is an entry in the "Data Entry" Tab in Cell A2,
then calcuate in the "Costs" tab and put the result in Cell A2. The total
file is trying to put monthly budget, actual and forecast for the next 5
years in one tab, hence it is Column A to IE.

I use Do Until, IF function and looping the code to calculate for me.
However, i am stuck not knowing how to add rows to the end of the "Calculated
Cost" within the calculated tab as user can insert as many lines as they want
in the "Data Entry Tab". i.e. the number of rows varies - it could be from 20
rows to 50 rows, etc

I would like:
1. add a which total up Cell A2:Cell A (wherever) underneath the costs for
each month
2. add a blank row underneath the total and add another row again which puts
in a subtotal function (as user uses autofilter for specific
departments/grades/name, it is necessary for them to have this function).

I would give you the code I've entered so far, but it is very long and think
it is not useful here...but I can supply it if this is necessary!!

I hope someone can help me, I am sorry if I have confused and over
complicated this!!

Thanks a lot in advance

Vivi
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Add Total to End of columns


You can get the last filled row using the below code and then use that in the
formula or for calculation

'Last row filled in Column A
lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row

If this post helps click Yes
---------------
Jacob Skaria


"vivi" wrote:

Hi there, my query is very complicated and hope someone can help me!!!

I have created 2 tabs, one is for data entry (Man days entry) and the second
one is for calculations (Rate * Days) and variance calculations. For the
calculation tab, i have created a macro and so far it is working fine.
Basically it says if there is an entry in the "Data Entry" Tab in Cell A2,
then calcuate in the "Costs" tab and put the result in Cell A2. The total
file is trying to put monthly budget, actual and forecast for the next 5
years in one tab, hence it is Column A to IE.

I use Do Until, IF function and looping the code to calculate for me.
However, i am stuck not knowing how to add rows to the end of the "Calculated
Cost" within the calculated tab as user can insert as many lines as they want
in the "Data Entry Tab". i.e. the number of rows varies - it could be from 20
rows to 50 rows, etc

I would like:
1. add a which total up Cell A2:Cell A (wherever) underneath the costs for
each month
2. add a blank row underneath the total and add another row again which puts
in a subtotal function (as user uses autofilter for specific
departments/grades/name, it is necessary for them to have this function).

I would give you the code I've entered so far, but it is very long and think
it is not useful here...but I can supply it if this is necessary!!

I hope someone can help me, I am sorry if I have confused and over
complicated this!!

Thanks a lot in advance

Vivi

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Add Total to End of columns

Here are two ways to sum a variable range, placing the result in the first
empty cell at the end of the range:

Sub SumAtEnd()
firstempty = Range("A2").End(xlDown).Row + 1
Range("A" & firstempty).Formula = "=SUM(A2:A" & firstempty - 1 & ")"
End Sub

Sub VariableSum()
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row + 1
Cells(lastrow, "A").FormulaR1C1 _
= "=sum(r2c:r[-1]c)"
End Sub

Note, the summing starts in Call A2.

HTH,
Ryan---
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Jacob Skaria" wrote:

You can get the last filled row using the below code and then use that in the
formula or for calculation

'Last row filled in Column A
lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row

If this post helps click Yes
---------------
Jacob Skaria


"vivi" wrote:

Hi there, my query is very complicated and hope someone can help me!!!

I have created 2 tabs, one is for data entry (Man days entry) and the second
one is for calculations (Rate * Days) and variance calculations. For the
calculation tab, i have created a macro and so far it is working fine.
Basically it says if there is an entry in the "Data Entry" Tab in Cell A2,
then calcuate in the "Costs" tab and put the result in Cell A2. The total
file is trying to put monthly budget, actual and forecast for the next 5
years in one tab, hence it is Column A to IE.

I use Do Until, IF function and looping the code to calculate for me.
However, i am stuck not knowing how to add rows to the end of the "Calculated
Cost" within the calculated tab as user can insert as many lines as they want
in the "Data Entry Tab". i.e. the number of rows varies - it could be from 20
rows to 50 rows, etc

I would like:
1. add a which total up Cell A2:Cell A (wherever) underneath the costs for
each month
2. add a blank row underneath the total and add another row again which puts
in a subtotal function (as user uses autofilter for specific
departments/grades/name, it is necessary for them to have this function).

I would give you the code I've entered so far, but it is very long and think
it is not useful here...but I can supply it if this is necessary!!

I hope someone can help me, I am sorry if I have confused and over
complicated this!!

Thanks a lot in advance

Vivi

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
Total column changes colors when total equals sum of other columns newstacy New Users to Excel 1 April 21st 07 09:00 PM
Average the total of 3 columns belvy123 Excel Discussion (Misc queries) 1 February 21st 07 09:55 AM
Total width of several columns. Basher Bates Excel Worksheet Functions 2 April 17th 06 12:38 PM
how do i add up 3 columns to get a total dekmag New Users to Excel 5 December 26th 05 08:00 PM
Total No of Columns in Worksheet Andrew Schmidt Excel Programming 2 November 11th 03 03:15 AM


All times are GMT +1. The time now is 05:25 PM.

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"