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 "TOTAL" and summing column

I pull in an array of data and format it into a report.
Here's my problem:

In column H I need to insert the word "TOTAL" in the
second blank row below the last entry in the array.

In the same row, column J, I need to insert"=sum(j4:j
[whatever])" to sum the values in column J.

The number of rows can vary from 2 or 3 to several
thousand. Sometimes there are entries that take more than
one row for the data in the other columns, creatng empty
cells in H and J.

I've got everything else worked out except getting the
total in. Anyone have an idea or suggest a place to look?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Adding "TOTAL" and summing column

Hi
you may post your existing code. Makes it easier to add the missing
parts

--
Regards
Frank Kabel
Frankfurt, Germany


Fred Butterfield wrote:
I pull in an array of data and format it into a report.
Here's my problem:

In column H I need to insert the word "TOTAL" in the
second blank row below the last entry in the array.

In the same row, column J, I need to insert"=sum(j4:j
[whatever])" to sum the values in column J.

The number of rows can vary from 2 or 3 to several
thousand. Sometimes there are entries that take more than
one row for the data in the other columns, creatng empty
cells in H and J.

I've got everything else worked out except getting the
total in. Anyone have an idea or suggest a place to look?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Adding "TOTAL" and summing column

The following code insert TOTAL and the SUM function:

'======================
Dim r As Long
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
r = ws.Cells(Rows.Count, 10).End(xlUp).Row + 2
ws.Cells(r, 8).Value = "TOTAL"
ws.Cells(r, 10).Formula = "=SUM(J4:J" & r - 2 & ")"
'=========================

Fred Butterfield wrote:
I pull in an array of data and format it into a report.
Here's my problem:

In column H I need to insert the word "TOTAL" in the
second blank row below the last entry in the array.

In the same row, column J, I need to insert"=sum(j4:j
[whatever])" to sum the values in column J.

The number of rows can vary from 2 or 3 to several
thousand. Sometimes there are entries that take more than
one row for the data in the other columns, creatng empty
cells in H and J.

I've got everything else worked out except getting the
total in. Anyone have an idea or suggest a place to look?



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding "TOTAL" and summing column

Fred

Try thnis

Code gets row number of last used cell in Column H


Dim LastRow As Long

LastRow = Cells(Rows.Count, "h") _
.End(xlUp).Row

Cells(LastRow + 2, "h").Value = "TOTAL"

Cells(LastRow + 2, "j").Value = _
"=sum(j4:j" & LastRow & ")

--
Message posted from http://www.ExcelForum.com

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
Adding data only if adjacent to cell labeled "male"/"female" lovesrubbaducky Excel Worksheet Functions 1 November 23rd 09 05:49 PM
Column "SUM" Not SUMming Mumsy Excel Discussion (Misc queries) 2 August 3rd 08 10:05 PM
Need column evaluated to count total of occurrences of "Y". How? learning Excel Worksheet Functions 2 June 12th 06 01:55 AM
Linking two "total" pages to create a "Complete Total" page Jordon Excel Worksheet Functions 0 January 10th 06 11:18 PM
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc Bob Reynolds[_2_] Excel Programming 0 March 4th 04 08:52 PM


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