Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find last empty row

Hi

I made a mess of my last post, but here goes.

I would like to be able to find the last empty row in a worksheet ski
one row and then sum up the totals of each column in this row.

I hope this is clearer than my last post
Thanx for your help

Kind Regard

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Find last empty row

The following inserts a formula in the last empty row of a column and sums
all values.
You can adpat this for the column, range etc as required

Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Cells(lastrow + 1, 1).Formula = "=sum(A1:A" & lastrow & ")"


Cheers
Nigel


"poppy " wrote in message
...
Hi

I made a mess of my last post, but here goes.

I would like to be able to find the last empty row in a worksheet skip
one row and then sum up the totals of each column in this row.

I hope this is clearer than my last post
Thanx for your help

Kind Regards


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Find last empty row

Have you thought about putting the totals at the top of your data rather
than at the bottom. Then the formula can sum right down to 65000 if you
want, and no need for a macro at all.

Chris


"poppy " wrote in message
...
Hi

I made a mess of my last post, but here goes.

I would like to be able to find the last empty row in a worksheet skip
one row and then sum up the totals of each column in this row.

I hope this is clearer than my last post
Thanx for your help

Kind Regards


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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Find last empty row

When I put the totals at the top, I'll also use the =subtotal() function. Then
when I apply data|Filter|autofilter, I get to see the subtotals for the visible
rows.



"Chris.F" wrote:

Have you thought about putting the totals at the top of your data rather
than at the bottom. Then the formula can sum right down to 65000 if you
want, and no need for a macro at all.

Chris

"poppy " wrote in message
...
Hi

I made a mess of my last post, but here goes.

I would like to be able to find the last empty row in a worksheet skip
one row and then sum up the totals of each column in this row.

I hope this is clearer than my last post
Thanx for your help

Kind Regards


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


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find last empty row

Thanx Nigel

I works fine except for one small detail. When I run the macro for
second time it gives me problems. I think this is becuase I do a fil
function and I have hardcoded the destination fill. Does that mak
sense to you?


Code
-------------------
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
Cells(lastrow + 1, 1) = "TOTAL"
Cells(lastrow + 1, 2).Formula = "=sum(B3:B" & lastrow & ")"

'format totals
Cells(lastrow + 1, 2).Select
Selection.AutoFill Destination:=Range("B156:K156"), Type:=xlFillDefault ' I think the problem is here. I need to have a
variable that will change according to number of rows

Rows("156:156").Select
Selection.Font.Bold = True
With Selection.Font
.Name = "Arial"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

Range("B3:O157").Select
Selection.Replace What:="", Replacement:="0.00", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Range("B:B,D:D,F:F,H:H,J:J,L:L,N:N").Select
Selection.NumberFormat = "0"
Range("C:C,E:E,G:G,I:I,K:K,M:M,O:O").Select
Selection.NumberFormat = "#,##0.00"


-------------------


Thanx agai

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Find last empty row

I guess two points

1. If you run the macro twice it will put the total in twice, since the code
to find the last row will be moved on to the total created in the first
run - not a good idea!

2. Your fill is OK just change the reference to the lastrow variable, so in
the part where you specify the range use

Range("B" & lastrow & ":K" & lastrow)

or use to allow control of columns using a loop or variable (if required)

Range(Cells(ir, 2), Cells(ir, 11))

Cheers
Nigel

"poppy " wrote in message
...
Thanx Nigel

I works fine except for one small detail. When I run the macro for a
second time it gives me problems. I think this is becuase I do a fill
function and I have hardcoded the destination fill. Does that make
sense to you?


Code:
--------------------
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
Cells(lastrow + 1, 1) = "TOTAL"
Cells(lastrow + 1, 2).Formula = "=sum(B3:B" & lastrow & ")"

'format totals
Cells(lastrow + 1, 2).Select
Selection.AutoFill Destination:=Range("B156:K156"), Type:=xlFillDefault

' I think the problem is here. I need to have a
variable that will change according to number of rows

Rows("156:156").Select
Selection.Font.Bold = True
With Selection.Font
.Name = "Arial"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

Range("B3:O157").Select
Selection.Replace What:="", Replacement:="0.00", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Range("B:B,D:D,F:F,H:H,J:J,L:L,N:N").Select
Selection.NumberFormat = "0"
Range("C:C,E:E,G:G,I:I,K:K,M:M,O:O").Select
Selection.NumberFormat = "#,##0.00"


--------------------


Thanx again


---
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
To find row is empty or not pol Excel Discussion (Misc queries) 2 July 27th 09 01:22 PM
Find first empty row [email protected] Excel Discussion (Misc queries) 3 July 29th 06 07:52 PM
How to find next value if rows between are empty? joes Excel Discussion (Misc queries) 2 June 16th 06 04:26 PM
find the next empty row ASU Excel Discussion (Misc queries) 2 June 12th 06 10:05 AM
Find Next Empty Row Myrna Rodriguez Excel Programming 3 June 9th 04 08:32 AM


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