Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default how do I add a row when the second last one is used

Can't tell from your post which column is used for totals and how the data
gets entered but for example assume column A

Enter this formula in A2

=SUM(A1:INDEX(A:A,ROW()-1))

Paste this event code into your worksheet then start entering numbers in A1.

A row will be inserted and the SUM range will expand to include the new row.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If Range("A" & n).Value < "" Then
Range("A" & n).Offset(1, 0).EntireRow.Insert
End If
End If
enditall:
Application.EnableEvents = True
End Sub

Right-click on your sheet tab and "View Code". Copy/paste the code into
that module. Edit to suit then Alt + q to return to the Excel window.


Gord Dibben MS Excel MVP

On Sun, 7 Sep 2008 16:39:01 -0700, Scott
wrote:

I am setting up a Invoice and I want to be able to add a new row whenever the
second last one is used. ( the last one contains the totals )

ie: if row 22 is used then it creates a new row (using the same type of
format as before)
I know this is a easy task but I am still a beginner trying to lealn this
program I am not sure of how to do this task.

Thanks in advance


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



All times are GMT +1. The time now is 11:47 AM.

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"