Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default I want to create a "Insert Row" button to insert a new row at the.

I want to create a "Insert new row" button to insert new rows at the bottom
of my table that contains the same functions as previous rows...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default I want to create a "Insert Row" button to insert a new row at the.

Assuming your data starts in Cell A1, your button could run the code:

Sub NewRow()

Application.ScreenUpdating = False

Dim lastRow As Long
Dim lastCol As Long
Dim startrng As Range

Set startrng = ActiveCell

lastRow = Cells(Rows.Count, "A").End(xlUp).Row
lastCol = Cells("1", Columns.Count).End(xlToLeft).Column

Range(Cells(lastRow, 1), Cells(lastRow, lastCol)).Copy
Range(Cells(lastRow + 1, 1), Cells(lastRow + 1, lastCol)) _
.PasteSpecial Paste:=xlPasteFormulas
Range(Cells(lastRow + 1, 1), Cells(lastRow + 1, lastCol)) _
.PasteSpecial Paste:=xlPasteFormats

On Error Resume Next
Range(Cells(lastRow + 1, 1), Cells(lastRow + 1, lastCol)) _
.SpecialCells(xlCellTypeConstants).ClearContents

Application.Goto startrng

Application.CutCopyMode = False
Application.ScreenUpdating = True

End Sub

Regards
Rowan

"Georges" wrote:

I want to create a "Insert new row" button to insert new rows at the bottom
of my table that contains the same functions as previous rows...

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
insert objects in .xlsx fails with message "cannot insert object" clacketwood Excel Discussion (Misc queries) 0 February 18th 10 12:16 PM
Lost "File Menu" - now it's "Edit / View / Insert.." but no "F daves Excel Discussion (Misc queries) 3 April 24th 07 04:52 AM
Insert "SAVE" Button in Excel Kevinb Excel Worksheet Functions 0 January 31st 07 02:44 PM
Insert "-" in text "1234567890" to have a output like this"123-456-7890" Alwyn Excel Discussion (Misc queries) 3 October 25th 05 11:36 PM
"cannot insert object" in Excel (even a button from Control Toolbox) Matthew Lee Excel Programming 1 April 30th 04 05:58 PM


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