LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Inserting Row

That should work okay Patrick. If you inserted say 2 rows at row 50, that
will change to =SUM(J21:J99). What does yours say?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Patrick Bateman" wrote in
message ...
for example

=SUM(J21:J97)

Regards

Patrick

"Bob Phillips" wrote:

What formula are you using in the totals row, it should expand just the
same.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Patrick Bateman" wrote in
message ...
Hi

I am looking for a way to insert a new row by pressing a button at the
end
of the row, letting the user choose how many rows to insert, then
inserting
the row(s) under the selected row and copying the format and any
formulas
down, but not values.

from a code i found on a website i have built it up to the following
code:


Sub InsertRowsAndFillFormulas(Optional vRows As Long = 0)


Dim x As Long

s = Application.Caller

ActiveSheet.Buttons(s).TopLeftCell.EntireRow.Selec t

If vRows = 0 Then
vRows = Application.InputBox(Prompt:= _
"How many rows do you want to add?", Title:="Add Rows", _
Default:=1, Type:=1)
If vRows = False Then Exit Sub
End If


Dim sht As Worksheet, shts() As String, i As Long
ReDim shts(1 To Worksheets.Application.ActiveWorkbook. _
Windows(1).SelectedSheets.Count)
i = 0
For Each sht In _
Application.ActiveWorkbook.Windows(1).SelectedShee ts
Sheets(sht.Name).Select
i = i + 1
shts(i) = sht.Name

x = Sheets(sht.Name).UsedRange.Rows.Count

Selection.Resize(rowsize:=2).Rows(2).EntireRow. _
Resize(rowsize:=vRows).Insert Shift:=xlDown

Selection.AutoFill Selection.Resize( _
rowsize:=vRows + 1), xlFillDefault

On Error Resume Next

Selection.Offset(1).Resize(vRows).EntireRow. _
SpecialCells(xlConstants).ClearContents
Next sht
Worksheets(shts).Select
End Sub

This is called from a button on the row. This works fine and does
everything
i want, but the problem is i have a row of totals at the bottom which
sum
up
the columns and unlike when a normal 'insert row' is used and the range
specified in the sum increases to accomodate it, this is not happening
with
using this code to insert a row.

any help or ideas would be much appreciated

Thankyou

Patrick









 
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
Inserting a row Pootle Excel Discussion (Misc queries) 7 February 24th 09 04:41 PM
Inserting a row below Belgarth Excel Discussion (Misc queries) 1 January 23rd 06 07:48 PM
Inserting zero ananga Excel Discussion (Misc queries) 2 July 1st 05 05:41 PM
Inserting a row Lee Excel Programming 1 February 19th 04 08:10 PM
Inserting a Row with VBA Thomas M Excel Programming 7 November 29th 03 05:33 AM


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