#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default adding rows

I have a sheet with formulas referencing cells in the same
row.

At the bottom of the sheet are totals for the different
columns.

Periodically I need to add more entries to the sheet.
This requires me to insert cells between the last entry
and the totals at the bottom. Then I need to copy the
formulas from one row down to the newly inserted rows.

Can I create a macro that will do that automatically - or
at least when directed by a command button? If so, how
would I do that?

TIA Papa
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default adding rows

Hi
have a look at
http://www.mvps.org/dmcritchie/excel/insrtrow.htm

--
Regards
Frank Kabel
Frankfurt, Germany

"papa" schrieb im Newsbeitrag
...
I have a sheet with formulas referencing cells in the same
row.

At the bottom of the sheet are totals for the different
columns.

Periodically I need to add more entries to the sheet.
This requires me to insert cells between the last entry
and the totals at the bottom. Then I need to copy the
formulas from one row down to the newly inserted rows.

Can I create a macro that will do that automatically - or
at least when directed by a command button? If so, how
would I do that?

TIA Papa


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default adding rows

Hi Papa,

Here is code to do the copy.

Dim iLastRow As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Cells(iLastRow, "A").EntireRow.Insert
Cells(iLastRow - 1, "A").EntireRow.Copy
Cells(iLastRow, "A").PasteSpecial Paste:=xlFormulas

Put it in a macro, and just assign the macro to a button.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"papa" wrote in message
...
I have a sheet with formulas referencing cells in the same
row.

At the bottom of the sheet are totals for the different
columns.

Periodically I need to add more entries to the sheet.
This requires me to insert cells between the last entry
and the totals at the bottom. Then I need to copy the
formulas from one row down to the newly inserted rows.

Can I create a macro that will do that automatically - or
at least when directed by a command button? If so, how
would I do that?

TIA Papa



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default adding rows

Bob,
This works great. How can I tweak it so that I also carry
the formatting down as well. By formating I mean borders
and such.
Papa

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

Here is code to do the copy.

Dim iLastRow As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Cells(iLastRow, "A").EntireRow.Insert
Cells(iLastRow - 1, "A").EntireRow.Copy
Cells(iLastRow, "A").PasteSpecial Paste:=xlFormulas

Put it in a macro, and just assign the macro to a button.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"papa" wrote in message
...
I have a sheet with formulas referencing cells in the

same
row.

At the bottom of the sheet are totals for the different
columns.

Periodically I need to add more entries to the sheet.
This requires me to insert cells between the last entry
and the totals at the bottom. Then I need to copy the
formulas from one row down to the newly inserted rows.

Can I create a macro that will do that automatically -

or
at least when directed by a command button? If so, how
would I do that?

TIA Papa



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default adding rows

Hi Papa,

Dim iLastRow As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Cells(iLastRow, "A").EntireRow.Insert
Cells(iLastRow - 1, "A").EntireRow.Copy
Cells(iLastRow, "A").PasteSpecial Paste:=xlFormulas
Cells(iLastRow, "A").PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"papa" wrote in message
...
Bob,
This works great. How can I tweak it so that I also carry
the formatting down as well. By formating I mean borders
and such.
Papa

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

Here is code to do the copy.

Dim iLastRow As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Cells(iLastRow, "A").EntireRow.Insert
Cells(iLastRow - 1, "A").EntireRow.Copy
Cells(iLastRow, "A").PasteSpecial Paste:=xlFormulas

Put it in a macro, and just assign the macro to a button.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"papa" wrote in message
...
I have a sheet with formulas referencing cells in the

same
row.

At the bottom of the sheet are totals for the different
columns.

Periodically I need to add more entries to the sheet.
This requires me to insert cells between the last entry
and the totals at the bottom. Then I need to copy the
formulas from one row down to the newly inserted rows.

Can I create a macro that will do that automatically -

or
at least when directed by a command button? If so, how
would I do that?

TIA Papa



.





  #6   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default adding rows

Also,
I have buttons that run macros for sorting my spreadsheet
in different ways. I have had to go in and manually
update the macros manually to change the range that gets
sorted to include the newly inserted rows.

Can this be automated?
TIA
Papa


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

Here is code to do the copy.

Dim iLastRow As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Cells(iLastRow, "A").EntireRow.Insert
Cells(iLastRow - 1, "A").EntireRow.Copy
Cells(iLastRow, "A").PasteSpecial Paste:=xlFormulas

Put it in a macro, and just assign the macro to a button.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"papa" wrote in message
...
I have a sheet with formulas referencing cells in the

same
row.

At the bottom of the sheet are totals for the different
columns.

Periodically I need to add more entries to the sheet.
This requires me to insert cells between the last entry
and the totals at the bottom. Then I need to copy the
formulas from one row down to the newly inserted rows.

Can I create a macro that will do that automatically -

or
at least when directed by a command button? If so, how
would I do that?

TIA Papa



.

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 rows based on no of rows specified from a given position nanette Excel Worksheet Functions 1 July 9th 08 02:29 PM
Adding five new rows every 40 rows in a spreadsheet? Olzki Excel Discussion (Misc queries) 8 May 18th 07 02:14 AM
Adding rows? cambanis Excel Worksheet Functions 3 September 17th 06 10:48 PM
Adding Rows offsets to working rows across two worksheets tom Setting up and Configuration of Excel 3 July 30th 06 07:54 PM
adding rows Graeme Moloney Excel Discussion (Misc queries) 1 May 23rd 05 02:00 PM


All times are GMT +1. The time now is 05:01 PM.

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"