PC Review


Reply
Thread Tools Rate Thread

Add Total to End of columns

 
 
vivi
Guest
Posts: n/a
 
      7th Jul 2009
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 With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      7th Jul 2009

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 With Quote
 
ryguy7272
Guest
Posts: n/a
 
      7th Jul 2009
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
TOTAL COLUMNS Pat Microsoft Access Queries 3 23rd Feb 2009 05:07 PM
Total column changes colors when total equals sum of other columns =?Utf-8?B?bmV3c3RhY3k=?= Microsoft Excel New Users 1 21st Apr 2007 09:00 PM
how do i add up 3 columns to get a total =?Utf-8?B?ZGVrbWFn?= Microsoft Excel New Users 5 26th Dec 2005 08:00 PM
Help with mtd ytd and total columns Reggie Microsoft Excel Worksheet Functions 0 15th Sep 2004 05:32 PM
Total across columns bagia Microsoft Access Reports 2 25th Jun 2004 09:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:38 AM.