Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to: Add blank row at bottom of range

Hi,

What I want to do is the following:

I have a worksheet formatted as a printable table, with heading rows, then
the table value rows, and then a row that sums various columns. What I need
to do is to find the last row in the table value rows, add a new row between
this row and the row that sums the column values, and then put the info
enetred in the form into this new row. It also must update the sum() field
to include this row.

As an example, my worksheet looks something like this:


Heading
Date:

Ref | Location | Area | Comments |
| | | |
A | Left | 500 | LHS |
B | Right | 325 | RHS |
Totals | 825 |

What I need to do is insert a row after Ref "B", and then add data there
from a form. The totals must also be updated to reflect this added row.

How can I do this?

Thanks
Brad Clarke


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default How to: Add blank row at bottom of range

When you say "add data there from a form" are you talking about a
userform?

If so, assume that the values are in TextBox1 - TextBox4 and that
the data is to be entered when CommandButton1 is clicked:

Private Sub CommandButton1_Click()
With Sheets("Sheet6").Range("A:A").Find( _
What:="Totals", _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=True)
.EntireRow.Insert
.Offset(-1, 0).Resize(1, 4).Value = Array(TextBox1.Text, _
TextBox2.Text, TextBox3.Text, TextBox4.Text)
End With
End Sub

Your Totals cell should have a self-updating formula, something like
(assuming the Area header is in C4, say):

=SUM(OFFSET($C$4,,,ROW()-4,1))

so that no adjustment is necessary.

In article ,
"Brad Clarke" wrote:

Hi,

What I want to do is the following:

I have a worksheet formatted as a printable table, with heading rows, then
the table value rows, and then a row that sums various columns. What I need
to do is to find the last row in the table value rows, add a new row between
this row and the row that sums the column values, and then put the info
enetred in the form into this new row. It also must update the sum() field
to include this row.

As an example, my worksheet looks something like this:


Heading
Date:

Ref | Location | Area | Comments |
| | | |
A | Left | 500 | LHS |
B | Right | 325 | RHS |
Totals | 825 |

What I need to do is insert a row after Ref "B", and then add data there
from a form. The totals must also be updated to reflect this added row.

How can I do this?

Thanks
Brad Clarke


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to: Add blank row at bottom of range

Hi, the quickest way to find the Totals row is to look for
the work 'Totals', although this assumes there are no
other similar tables on different rows. Once you've done
that, you just insert a row above the totals row. As long
as you have done the formulas correctly, they should
include the new row:

set totalsCell = ws.Columns(1).Find _
what:="Totals", lookat := xlWhole.

If Not totalsCell Is Nothing Then
totalsCell.offset(-1, 0).EntireRow.Insert shift:=xlDown
Call FunctionToInsertValuesInNewRow
End If.

You have to be careful after inserting a new row as the
range TotalsCell will then refer to the first cell in the
NEW row.

Regards, Andy


-----Original Message-----
Hi,

What I want to do is the following:

I have a worksheet formatted as a printable table, with

heading rows, then
the table value rows, and then a row that sums various

columns. What I need
to do is to find the last row in the table value rows,

add a new row between
this row and the row that sums the column values, and

then put the info
enetred in the form into this new row. It also must

update the sum() field
to include this row.

As an example, my worksheet looks something like this:


Heading
Date:

Ref | Location | Area | Comments |
| |

| |
A | Left | 500 | LHS |
B | Right | 325 | RHS |
Totals | 825 |

What I need to do is insert a row after Ref "B", and then

add data there
from a form. The totals must also be updated to reflect

this added row.

How can I do this?

Thanks
Brad Clarke


.

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
How do I get rid of a blank row at bottom of Excel spreadsheet? Kathy Excel Discussion (Misc queries) 1 April 23rd 09 07:15 PM
How do i delete blank lines at bottom of an Excel worksheet? JoeOvercoat Excel Discussion (Misc queries) 2 September 2nd 06 11:54 PM
Finding the bottom non-blank cell in a range Fenneth Excel Discussion (Misc queries) 7 July 6th 06 06:05 PM
Dynamic named list includes blank cell at bottom L Scholes Excel Discussion (Misc queries) 1 April 13th 06 06:13 PM
How do I delete blank rows at the bottom of a spreadsheet to get . Miklaurie Excel Discussion (Misc queries) 1 January 26th 05 02:30 PM


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