Insert row VBA code

Thank you for your help.  I am trying to build and find code like below
that will insert a row in columns A to P.  If I put my curser on A5 and
click on a macro button then it will insert a line on A6 from column A
to P.  Or if I put the curser on A10 or A50 that it would do the same
thing.  I have tried the code below and I know it is wrong for the
"Entire Row" is wrong.  But I cannot make it work.  Thank you for your
help.



Sub InsertRows()
Sheets("sheet1").Activate
Selection.EntireRow.Insert Shift:=xlDown
Sub yInsertA3P3CellsDown()
Range("A3:P3").Insert Shift:=xlDown
End Sub


---
Message posted from http://www.ExcelForum.com/

0
DDH.z7g3y (1)
12/29/2003 3:26:22 PM
excel.misc 78881 articles. 5 followers. Follow

2 Replies
775 Views

Similar Articles

[PageSpeed] 45

Selection.Resize(1,16).insert shift:=xlDown

Bob Umlas
Excel MVP

"DDH" <DDH.z7g3y@excelforum-nospam.com> wrote in message
news:DDH.z7g3y@excelforum-nospam.com...
> Thank you for your help.  I am trying to build and find code like below
> that will insert a row in columns A to P.  If I put my curser on A5 and
> click on a macro button then it will insert a line on A6 from column A
> to P.  Or if I put the curser on A10 or A50 that it would do the same
> thing.  I have tried the code below and I know it is wrong for the
> "Entire Row" is wrong.  But I cannot make it work.  Thank you for your
> help.
>
>
>
> Sub InsertRows()
> Sheets("sheet1").Activate
> Selection.EntireRow.Insert Shift:=xlDown
> Sub yInsertA3P3CellsDown()
> Range("A3:P3").Insert Shift:=xlDown
> End Sub
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>


0
rumlas (268)
12/29/2003 4:13:16 PM
One way:

    Public Sub InsertRow()
        Cells(ActiveCell.Row + 1, 1).Resize(1, 17).Insert _
             Shift:=xlDown
    End Sub


In article <DDH.z7g3y@excelforum-nospam.com>,
 DDH <DDH.z7g3y@excelforum-nospam.com> wrote:

> Thank you for your help.  I am trying to build and find code like below
> that will insert a row in columns A to P.  If I put my curser on A5 and
> click on a macro button then it will insert a line on A6 from column A
> to P.  Or if I put the curser on A10 or A50 that it would do the same
> thing.  I have tried the code below and I know it is wrong for the
> "Entire Row" is wrong.  But I cannot make it work.  Thank you for your
> help.
> 
> 
> 
> Sub InsertRows()
> Sheets("sheet1").Activate
> Selection.EntireRow.Insert Shift:=xlDown
> Sub yInsertA3P3CellsDown()
> Range("A3:P3").Insert Shift:=xlDown
> End Sub
> 
> 
> ---
> Message posted from http://www.ExcelForum.com/
>
0
jemcgimpsey (6723)
12/29/2003 4:13:55 PM
Reply:

Similar Artilces:

How do I insert Roman Numerals?
New to Word 2007 would someone please explain to me how to insert Roman Numerlas in my document? "ckj" <ckj@discussions.microsoft.com> wrote in message news:6CF0C580-BA6E-463D-B4FD-E6A6FDD9E814@microsoft.com... > New to Word 2007 would someone please explain to me how to insert Roman > Numerlas in my document? Just type them... I II III IV V VI VII VIII IX X XI etc etc. Type a number e.g. 21, select it and run the following macro Dim oRng As Range Set oRng = Selection.Range oRng.Fields.Add oRng, 34, oRng.Text & " \*Roman"...

Linking a Column List to a Row List #2
Thanks for the help, it worked perfectly -- Mo ----------------------------------------------------------------------- Moe's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1250 View this thread: http://www.excelforum.com/showthread.php?threadid=27428 ...

Covert javascripts to use in code behind form
How to convert a javascripts below to use in code behind form? <script type="text/javascript"> document.getElementById('Ok').disabled = true; setTimeout(function(){ document.getElementById('Ok').disabled = false; }, 15000); </script> Convert to: Dim strJScript As New StringBuilder strJScript.Append("document.getElementById('" + Ok.ClientID + "').disabled =true;") //help to convert below code: ------ setTimeout(function(){ document.getElementById('Ok').disabled = false; }, 15000); -----...

Alternate Row Shading
I'm a newbie who's got a five-column worksheet and about 900 rows, most of them already typed. Grateful if someone could advise how to shade all of the rows in an alternate fashion, i.e., light-gray, then dark-gray, etc. Thanks! AB Hi see: http://www.cpearson.com/excel/banding.htm -- Regards Frank Kabel Frankfurt, Germany Alex_Bachrach wrote: > I'm a newbie who's got a five-column worksheet and about 900 rows, > most of them already typed. Grateful if someone could advise how to > shade all of the rows in an alternate fashion, i.e., light-gray, then > dark-...

VBA with Modifier or Dexterity with Modifier
I had to modify a few forms in the HR dictionary as i have to add/remove a few fields, so i am using modifier with vba to save/retrive/delete data for my fields. I had added a local field to the window with modifier and saving/retriving its value with VBA, now upon value returning from lookup or navigating through records each time i am being prompt to save record message box even though,i havent touched any field, i had put my VBA code on ID field's Changed event. Also i lose data and ID if i put delete code on Delete_AfterUserChanged event so i had to put it on the Delete_Before...

Excel
When using auto-filtering, how can I "number" how many records are displayed. Your question has fallen into an Access news group. Try an Excel news group for a better chance at getting a quick answer. -- Duane Hookom Microsoft Access MVP "Rachel" wrote: > When using auto-filtering, how can I "number" how many records are displayed. "Rachel" <Rachel@discussions.microsoft.com> 在郵件 news:DE18E8EF-5A6D-4661-A768-41D3B4D85D6C@microsoft.com 中撰寫... > When using auto-filtering, how can I "number" how many records are ...

How To Copy Rows without Work Art
I have some Word Art in say Rows 9-23, I use some Macro code to copy cells 9-23 down to 10 grouped rows below 23, but everytime I run the Macro it also copies a 'New' Work Art over the existing Art below Row 15. My fear is that my file size will balloon. My code simply states Sheets("Starters").Select Rows("9:23").Select Selection.Copy Range("A25").Select ActiveSheet.Paste Range("A41").Select ActiveSheet.Paste How can I copy Rows 9-23 without the WorkArt also (which is 'floating' over Rows 14-18) Thanks Anot...

Insert trigger
Looking for some advice on SQL 2005. I have a table that will usually be populated by an SSIS package. I want to set the "loaddate" column to the current time after a record is inserted. Should i do this via trigger or should i just build a step in the SSIS package to update the column after the file loads? If trigger is the way to go, what is the syntax to create the after insert trigger? Thanks in advance. You can create a default constraint on the table set to CURRENT_TIMESTAMP. That will handle the automatic date assignment without any need for coding. -...

empty rows at bottom of worksheet
My worksheet has about 66,000 empty rows at the bottom of the sheet and that affects my usage of the scrollbar on the right of the screen. Anyone know how i can get rid of those miscellaneous rows? Michael If you will turn on the page break preview (piece of paper with a magnifying glass) which is the icon on the on the Standard Toolbar to the right of the Printer icon it will show you exactly what is going to print. There are solid blue lines that the edge of the page, the dashed blue lines are soft page breaks. Find the solid blue line at the bottom of the spreadsheet and drag it ...

inserting hrs and minutes
I have a cell in my time card that displays total weekly time -ex- "40:15" is there a way to make it more like this...40hrs,15mins -- Message posted from http://www.ExcelForum.com Use a custom format hh"hrs",mm"mins" -- Regards, Peo Sjoblom "-Brian-H- >" <<Brian-H-.110wgs@excelforum-nospam.com> wrote in message news:Brian-H-.110wgs@excelforum-nospam.com... > I have a cell in my time card that displays total weekly time -ex- > "40:15" is there a way to make it more like this...40hrs,15mins ? > > > ...

insert an interactive excel file into word web page
I'm trying to insert a excel file into a word document with text, and then save it was as a web page, but I want to keep the excel part interactive. Any ideas? ...

VBA Help Please
I have a data entry sheet with a column called �Priority� and a colum called �Start Flag�. I have a chart (not a PivotChart) which is located as an object in spreadsheet. I am trying to develop VBA code which will do the following: Upon activation of the spreadsheet containing the chart: Check each row (record) of the data entry sheet and count the record where Priority = �E� and Start Flag = �TRUE� Enter the result in a certain cell of the spreadsheet Check each row (record) of the data entry sheet and count the record where Priority = �O� and Start Flag = �TRUE� Enter the result in a cer...

Insert | File > Attachmnet-Button Drop Down ;What is the difference between Insert and Insert As Attachmnet
re: "Outlook2003, File-Insert-Options" On making new-email with Attachment-File(s), ** File Menu | Insert | File >>> (Brows and select File to insert ) then we can see the button "Insert", and write side Drop Down Arrow lower-right side of Dialog Box; If it clicked, we can see three options as follows: ** Insert Insert as text Insert as Attachment I can not recognize/understand the difference between "Insert" and "Insert as Attachment" *** What is the difference between Insert and Insert As Attachment ? I would appreciate y...

Empty rows
When I do Shift+Page Down+End+Arrow Down from the first selected row, it goes to row 65,536. How do I get it to go to the end of the report (the last typed row)? Connie Hi clear your used range first: http://www.contextures.com/xlfaqApp.html#Unused -- Regards Frank Kabel Frankfurt, Germany "Connie Martin" <Connie Martin@discussions.microsoft.com> schrieb im Newsbeitrag news:61708D1A-8D45-4213-A35A-54953A8C90E5@microsoft.com... > When I do Shift+Page Down+End+Arrow Down from the first selected row, it goes > to row 65,536. How do I get it to go to the end of the re...

Inserting Hyperlinks in a Protected Sheet
Hi I run Excel 2000 and I have a protected worksheet that I share wit users in my organisation. I want to allow the insertion of a hyperlin to a specific file type within a specified directory on our server. 3 Questions: 1.Protection on disables the insert hyperlink command. Can this b overcome with worksheet activate code? 2.Can I limit the types of files (preferably by requiring the file t meet a mask format eg "z-*.xls")? 3.Can I limit the directory that can be linked, by referring to pathname stored in a cell on the active sheet? Would appreciate your suggestions. Thanks S...

Insert with a where condition
Hi, sql 2005 I have an insert statement that is ignoring the where condition. That is, I want to insert records when they do not already exist in the destination table. INSERT INTO dbo.tblmnuGroupPerm ( gId ,mtfID ,... ) SELECT @gID ,mtfID ,... FROM dbo.locmnuTabFunction AS ltf WHERE ltf.mtfID NOT IN ( SELECT gp.mtfID FROM dbo.tblmnuGroupPerm AS gp WHERE gp.gId=@gID AND gp.Deleted=0 ) Any ideas or recommendations appreciated :-) Many thanks, Jonathan It's OK... <oops "redFace">I did not correctly se...

Insert
I want to overtype in a Publisher text box. I find I can only insert. The "insert" key doesn't do anything. ...

New essay and code: Logarithmic Slider
I decided to be positively decadent, so I wrote another essay on a logarthmic slider control http://www.flounder.com/logslider.htm This is missing one feature of the pure-C implementation I give in the Win32 book: it doesn't have logarithmic tick marks. Perhaps someday... joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm ...

Auto Sum unknown number of rows
Im using odbc to import data from a database. Imported is a list of products in column A and then various columns containing sales figures. Because of the import from the database, I do not know how many rows of products will appear, this week we sell 500 different products, next week 550. I need to add totals to the columns directly under the last product. I've tried creating the totals in an empty template and then inserting the imported data so the total figures move down and appear at the bottom. However the imported data moves the total cells to the right instead of down. Tried ...

how to insert data in a table
Hi Exprets; I am creating an access database in which I want to insert data in already created table. Kindly help. Regards, Vikky Vikky <love.excel@gmail.com> wrote in news:1194124711.012302.269990 @e34g2000pro.googlegroups.com: > Hi Exprets; > > I am creating an access database in which I want to insert data in > already created table. > > Kindly help. > > Regards, > > Vikky > Data from where? Do you want to import it from excel, from a text file, copy it from another table or type it in manually? -- Bob Quintal PA is y I've altere...

Topic: Oh! NOOO! APOSTROPHE FOUND RE: Replace and Removing SQL VBA HELP!!!
Dear All,All nigth long and still do not know how to fix this query,This works fine until finds an apostrophe and I guess any otherstrange characterRun-time error '3075':Syntax error (missing operator) in query expression "C:\DVD APPZX\Appz Hp\hp drivers\hp\Drivers-Audio\Realteck AC'97 AudioDriver Update(English)' WHERE Tempinfo_Tbl.ID = 10165 ANDTempInfo_Tbl.DirFolder Like 'DIR*"The code replace in one step all the records from my TblTempInfo_Tbl:Actual Record: DIR Dups V.1.0\bas\2006\<Drive>:\Path\Folder\Folder....After Replace: C:\Dups V.1.0\bas\2006If ...

Writing Code
I am a novice at writing code so I need help. I am trying to create an input box to pop up in an excel form and have the information that was put in the box to drop into a particular cell? Help! sk, You could use something like this: Range("A1").Value = InputBox("Enter your name.") If you want to validate the entry, you can use: Range("A1").Value = Application.InputBox("Enter your name.", , , , , , , 2) which makes Excel validate that the user enters a string. HTH, Bernie MS Excel MVP "sk" <sk@discussions.microsoft.com> wrote in...

How do you insert page numbers larger than 1000?
I have my purchase orders set up as a Publisher document. When our organization upgraded from Publisher 2000 to Publisher 2002, the new version set parameters on the page numbers. This was one of those things that worked just fine in the previous version... Does anyone know how to turn it off or change it? Hi mregen (mregen@discussions.microsoft.com), in the newsgroups you posted: || I have my purchase orders set up as a Publisher document. When our || organization upgraded from Publisher 2000 to Publisher 2002, the new || version set parameters on the page numbers. This was one of those...

Select alternate rows to copy
I would like to select alternate rows within a range on a worksheet to copy to another sheet. Any ideas on how to do this? -- Christina Christina Use a spare column (I used B but any will do), enter this formula and copy down to the full extent of your data. You will get alternating TRUE, FALSE =MOD(ROW(A2),2)=0 Now invoke an autofilter (Data>Filter>Autofilter) and filter on which one you want. Copy that data and pate to another sheet. -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England nick_hodgeTAKETHISOUT@zen.co.uk.ANDTHIS "Christina" <Christina@disc...

insert downloads into power point
i downloaded an application called "BioDigital Simulator" of an animated cleft lip/palate surgery and need it put into my power point presentation, but can't fiugre out how to do so.... very frustrating... What kind of file is this application? Is it a video? If so, what kind? MPEG? AVI? MOV? Or is it an EXE file? Something else? Which version of PPT are you using? -- Echo [MS PPT MVP] http://www.echosvoice.com What's new in PPT 2010? http://www.echosvoice.com/2010.htm Fixing PowerPoint Annoyances http://tinyurl.com/36grcd PowerPoint 2007 Complete Makeover...