Copying a row and pasting the same below it with just formulas

Hi all,

I have 3 buttons in the same worksheet to copy a row and insert the
same below it. I have this macro running for 3 different places. See
my code below.

The problem is:

1) I want just the formulas/formatting to be pasted, and not the
constants.
2) And more importantly, if I use Button 1, then a row is added below
row 15 and the rows move down and so for Button 2, row 36 is different
now as it has moved down, if you understand? How do I keep it fixed
that it always copies row 36 even if a row is added above and the rows
move down. Same for Button 3.


Private Sub CommandButton1_Click()
    Range("15:15").Select
    Selection.Copy
    Selection.Insert Shift:=xlDown
End Sub

Private Sub CommandButton2_Click()
    Range("36:36").Select
    Selection.Copy
    Selection.Insert Shift:=xlDown
End Sub

Private Sub CommandButton3_Click()
    Range("41:41").Select
    Selection.Copy
    Selection.Insert Shift:=xlDown
End Sub
0
Shivam
2/12/2010 8:00:19 PM
excel.programming 6508 articles. 2 followers. Follow

3 Replies
932 Views

Similar Articles

[PageSpeed] 37

That is what is happening now. You are inserting at row 36. If you mean you 
want to insert where the original row 36 is NOW then name that cell rtm1 
(select cell in name box (left of formula box) type in rtm1. Now use this 
change and a row will be inserted wherever that cell is

Sub insertatfixedrow()
'Range("36:36").Select
'    Selection.Copy
'    Selection.Insert Shift:=xlDown

'use this instead
Range("rtm1").EntireRow.Insert
end sub

-- 
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett@gmail.com
"Shivam.Shah" <shivams22@gmail.com> wrote in message 
news:82516b25-102b-4eb8-937c-091021d5210b@o3g2000vbo.googlegroups.com...
> Hi all,
>
> I have 3 buttons in the same worksheet to copy a row and insert the
> same below it. I have this macro running for 3 different places. See
> my code below.
>
> The problem is:
>
> 1) I want just the formulas/formatting to be pasted, and not the
> constants.
> 2) And more importantly, if I use Button 1, then a row is added below
> row 15 and the rows move down and so for Button 2, row 36 is different
> now as it has moved down, if you understand? How do I keep it fixed
> that it always copies row 36 even if a row is added above and the rows
> move down. Same for Button 3.
>
>
> Private Sub CommandButton1_Click()
>    Range("15:15").Select
>    Selection.Copy
>    Selection.Insert Shift:=xlDown
> End Sub
>
> Private Sub CommandButton2_Click()
>    Range("36:36").Select
>    Selection.Copy
>    Selection.Insert Shift:=xlDown
> End Sub
>
> Private Sub CommandButton3_Click()
>    Range("41:41").Select
>    Selection.Copy
>    Selection.Insert Shift:=xlDown
> End Sub 

0
Don
2/12/2010 10:05:54 PM
Thanks Don, but my problem is that I want to copy and paste the row
with formulas. So, rows 15, 36 and 41 have formulas.....but when I run
the button for row 15, a new row (which is a copy of row 15) is added
and row 36 becomes 37, but the macro is still using the row 36 and not
changing itself to copy row 37 instead.

I tried naming the cell, but still the same thing happens. I think
because I am copying the row, your code won`t work as it just inserts
a new row.

Thanks,
Shivam


On Feb 12, 5:05=A0pm, "Don Guillett" <dguille...@gmail.com> wrote:
> That is what is happening now. You are inserting at row 36. If you mean y=
ou
> want to insert where the original row 36 is NOW then name that cell rtm1
> (select cell in name box (left of formula box) type in rtm1. Now use this
> change and a row will be inserted wherever that cell is
>
> Sub insertatfixedrow()
> 'Range("36:36").Select
> ' =A0 =A0Selection.Copy
> ' =A0 =A0Selection.Insert Shift:=3DxlDown
>
> 'use this instead
> Range("rtm1").EntireRow.Insert
> end sub
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> dguill...@gmail.com"Shivam.Shah" <shivam...@gmail.com> wrote in message
>
> news:82516b25-102b-4eb8-937c-091021d5210b@o3g2000vbo.googlegroups.com...
>
> > Hi all,
>
> > I have 3 buttons in the same worksheet to copy a row and insert the
> > same below it. I have this macro running for 3 different places. See
> > my code below.
>
> > The problem is:
>
> > 1) I want just the formulas/formatting to be pasted, and not the
> > constants.
> > 2) And more importantly, if I use Button 1, then a row is added below
> > row 15 and the rows move down and so for Button 2, row 36 is different
> > now as it has moved down, if you understand? How do I keep it fixed
> > that it always copies row 36 even if a row is added above and the rows
> > move down. Same for Button 3.
>
> > Private Sub CommandButton1_Click()
> > =A0 =A0Range("15:15").Select
> > =A0 =A0Selection.Copy
> > =A0 =A0Selection.Insert Shift:=3DxlDown
> > End Sub
>
> > Private Sub CommandButton2_Click()
> > =A0 =A0Range("36:36").Select
> > =A0 =A0Selection.Copy
> > =A0 =A0Selection.Insert Shift:=3DxlDown
> > End Sub
>
> > Private Sub CommandButton3_Click()
> > =A0 =A0Range("41:41").Select
> > =A0 =A0Selection.Copy
> > =A0 =A0Selection.Insert Shift:=3DxlDown
> > End Sub

0
Shivam
2/13/2010 4:01:17 AM
      If desired, send your file to my address below. I will only look if:
      1. You send a copy of this message on an inserted sheet
      2. You give me the newsgroup and the subject line
      3. You send a clear explanation of what you want
      4. You send before/after examples and expected results.


-- 
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett@gmail.com
"Shivam.Shah" <shivams22@gmail.com> wrote in message 
news:d321d41b-6d93-48a1-95d1-17e9c55ff90b@s17g2000vbs.googlegroups.com...
Thanks Don, but my problem is that I want to copy and paste the row
with formulas. So, rows 15, 36 and 41 have formulas.....but when I run
the button for row 15, a new row (which is a copy of row 15) is added
and row 36 becomes 37, but the macro is still using the row 36 and not
changing itself to copy row 37 instead.

I tried naming the cell, but still the same thing happens. I think
because I am copying the row, your code won`t work as it just inserts
a new row.

Thanks,
Shivam


On Feb 12, 5:05�pm, "Don Guillett" <dguille...@gmail.com> wrote:
> That is what is happening now. You are inserting at row 36. If you mean 
> you
> want to insert where the original row 36 is NOW then name that cell rtm1
> (select cell in name box (left of formula box) type in rtm1. Now use this
> change and a row will be inserted wherever that cell is
>
> Sub insertatfixedrow()
> 'Range("36:36").Select
> ' � �Selection.Copy
> ' � �Selection.Insert Shift:=xlDown
>
> 'use this instead
> Range("rtm1").EntireRow.Insert
> end sub
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> dguill...@gmail.com"Shivam.Shah" <shivam...@gmail.com> wrote in message
>
> news:82516b25-102b-4eb8-937c-091021d5210b@o3g2000vbo.googlegroups.com...
>
> > Hi all,
>
> > I have 3 buttons in the same worksheet to copy a row and insert the
> > same below it. I have this macro running for 3 different places. See
> > my code below.
>
> > The problem is:
>
> > 1) I want just the formulas/formatting to be pasted, and not the
> > constants.
> > 2) And more importantly, if I use Button 1, then a row is added below
> > row 15 and the rows move down and so for Button 2, row 36 is different
> > now as it has moved down, if you understand? How do I keep it fixed
> > that it always copies row 36 even if a row is added above and the rows
> > move down. Same for Button 3.
>
> > Private Sub CommandButton1_Click()
> > � �Range("15:15").Select
> > � �Selection.Copy
> > � �Selection.Insert Shift:=xlDown
> > End Sub
>
> > Private Sub CommandButton2_Click()
> > � �Range("36:36").Select
> > � �Selection.Copy
> > � �Selection.Insert Shift:=xlDown
> > End Sub
>
> > Private Sub CommandButton3_Click()
> > � �Range("41:41").Select
> > � �Selection.Copy
> > � �Selection.Insert Shift:=xlDown
> > End Sub

0
Don
2/13/2010 1:57:37 PM
Reply:

Similar Artilces:

DVD Copy Pro for Mac
[b]DVD Copy Pro for Mac[/b] is a DVD copy software that can support D9 to D5 compression. With simple operation, it can save DVD in four different ways including directly burning to DVD disc, saving as DVD folder, copying into DVD media format that can be played by DVD Player directly, and converting as ISO file for easy movie management. Now this cool Mac DVD Copy also supports the latest released Snow Leopard. You can download [b][url=http://www.dvd-copy-mac.net/download/dvd-copy-pro-mac.zip]DVD Copy Pro for Mac[/url][/b] freely right now. [b]More information:[/b][quote]http://www.dvd-...

What's wrong with this COUNTIF formula?
=COUNTIF(weekly355comp2000,">A105") A105=20000 There are a number of cells in the range greater than 20000 but the formula returns 0. thanks Try the following: =COUNTIF(weekly355comp2000,">"&A105) -- HTH, Laura Cook Appleton, WI "Dave Potter" <dpotter41 at chartertn NOSPAM dot net> wrote in message news:6ie9ov48p7tqv85ohpsbnuq7rgi1smtr21@4ax.com... > =COUNTIF(weekly355comp2000,">A105") > > A105=20000 > There are a number of cells in the range greater than 20000 but the > formula returns 0. > > thanks As ...

Can I "unlock" just one cell in a protected worksheet?
Is there any way I can unlock just one cell in a protected worksheet without removing the protection from the entire worksheet? I am working on a fairly complex worksheet that has 10-15 data entry cells. The rest of the worksheet contains formulas and informational text. I have the formulas pretty much debugged and working. I am now down to making mostly cosmetic changes to the text and formatting. I have marked all of the data entry cells in a different color to help me keep from overwriting a formula, but it still happens occasionally. I usually catch it right away and can recover with ...

Import/copy calendar in Outlook 2003
I got a new computer and installed Office 2003, and wanted to move my calendar to the new PC. I created a new data file called Personal Folders from Old PC. I wanted to copy my calendar OVER my current one in Personal Folders, but don't see a way to do so. I can copy my old calendar into the Pesonal Folders, but can't delete the new, empty Calendar. So I have Calendar, and Calendar 1 under my Personal Folders. Any way to just import/copy my reminders/appointments into my new calendar? Thanks for any advice. Ck G'Day Cathy, 1. Use the Folder List 2. Click on the OLD Cal...

Count Formula #4
I have a spreadsheet with three tabs. They all have people requesting time off...first sheet is for people requesting more than a week off - 2nd for 1 week at a time - 3rd for people just wanting 1 day off. The sheets have their name then 2 columns one for days off starting and the other for days off finishing (With the exception of people just wanting one day off) I would like to have another sheet counting the number of people off on a daily basis. It is easy enough using "counif" for the people asking for 1 day off...but I can't seem to easily break out the weekly...

Copy info from one workbook to another?
I have a problem I have a workbook with the function i want like a discribe here. The problem is i want to split the workbook but i don`t know how. Is it possible to have a main workbook with information from other workbooks at each worksheet? I have 20 workbooks with information. I would like to have a main workbook with on sheet1 every row from the 20workbooks with category1, on sheet2 every row from the 20workbooks with category2, etc, etc. The information in the 20workbooks in always only on sheet. The Colum in which the data is has no fix end. I go to fill in the rows trough a...

Formula to reach goal percentage of migrating customers
I am working on a formula and am stuck. I have a goal date that I want to have a certain percentage of customers migrated (90%). There are many weeks leading up to the goal date. I have the following criteria setup: Prior to Week-4 2% of base migrate Week-4 20% migrate Week-3 20% migrate Week-2 20% migrate Week-1 20% migrate Week-0 balance migrate How can I set up a formula on a declining base to reach my goal of 90%? ...

Row hieght formula
I was wondering if there is a formula for row height. I have a lon list, and I want each row that returns a 0 to collapse automatically. Anyone know how to do that -- funktasti ----------------------------------------------------------------------- funktastic's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1600 View this thread: http://www.excelforum.com/showthread.php?threadid=27473 You should hide them. I'm not too keen on Visual Basic, but that's where you'd need to go to automate it. If you'd like to do it manually you can filter the cel...

Grouping Rows
I need to group a bunch of rows but I am having some problems. The code lines below works great: Rows("5:8").Select Selection.Rows.Group but I need to group these rows 12,14,16,18,20,22,24,26,28,30. I tried Rows("12,14,16,18,20,22,24,26,28,30").Select Selection.Rows.Group but I get and Overflow error message. When I tried Me.Rows("12:12,14:14,16:16,18:18,20:20,22:22,24:24,26:26,28:28,30:30").Select Selection.Rows.Group I get a Type mismatch error message. What am I doing wrong? HI The 'Rows' object obviously do not ac...

Secondary Copy
Hi, My customer using Great Plains modified report(Primary Copy). Now he wants new report something similar to the modified GP report with very few changes. I tried to copy the modified report and planned to use us a secondary copy. But the report has temp tables, so I am unable to make secondary copy. Can some one help me in how to make a new report something similar to the modified report, where to launch it. Whether it is possible throught VBA & Modifier? Regards Selvakumar.S A report with a temporary table can only be a primary copy. This is because only a primary copy can b...

local copy of mail
How do you store a copy of all your mail on you local computer when using Exchange? You setup an OST/Offline Folders file. Check with your mail admin if they support that configuration. "Brandon Baker" <brandon@discussions.microsoft.com> wrote in message news:epNKuJ19FHA.4004@TK2MSFTNGP14.phx.gbl... > How do you store a copy of all your mail on you local computer when using > Exchange? > ...

Linking Cells in a row.
Hello, I am trying to link several cells in a row, so that when I sort one column, the rest of the row of information stays with the sorted cell. Thank you... Ben Register Hi Ben, All you need to do is highlight all the columns of the information. For example: If your "sort by" column is A and you want all information in columns B-F to stay with it, highlight A-F. Then you can highlight one cell in the group of cells that are highlighted. This shows up as a white cell within the highlighted area. press tab until the white box is in the column you want to sort by. ...

Just a simple Q Can someone just take a look at my Q? Please Please
Is there any websit that have information on Great Plains dedicated just to Great Plain, Is There any training facility to teach Great Plains in the DC, MD area or even good books Can anyone get Licence in Great Plains? Thanks http://www.microsoft.com/greatplains -- Brandon Smith Presentations Direct - "Document Finishing Solutions" http://www.presentationsdirect.com "msw" <msw@hotmail.com> wrote in message news:%23a1HndwsFHA.3452@TK2MSFTNGP14.phx.gbl... > Is there any websit that have information on Great Plains dedicated just > to > Great Plain, ...

Row amd column heading
I have received one excel file in which rows number (1,2...) and column name (A,B,...) are in some big font 18, or maybe more. I couldn't find option to make them standard. Thanks in advance, Emilija Hi Emilija, On you toolbar you should have a font box and next to it is the size of the font. Select the row and change the fontsize to 10 for instance. Help, Answer Wizard Change font size From the topics show, select the topic that matches "Change the font or font size" --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http...

Text to column and paste special transpose
Hi All, I have 1 table like this item_number qty ref 00010-001 3 U34,U36,U43 00013-001 2 U16,U21 12505-001 3 U32,U33,U42 12512-001 3 U5,U6,U27 and 1 want it to become like this item_number qty ref 00010-001 3 U34 00010-001 3 U36 00010-001 3 U43 00013-001 2 U16 00013-001 2 U21 12505-001 3 U32 12505-001 3 U33 12505-001 3 U42 12512-001 3 U5 12512-001 3 U6 12512-001 3 U27 Anybody can help me to program it in macro.. usually i do it manually and have to redo again do to careless. After using Text to Columns on Column C.......comma delimited.........Run the Reorganize macro. Sub ReOrganize...

Outlook 2000 SP3
How can I copy my mail and calendar to CD so that I can take my received and sent mail history to a new computer with Outlook installed? Thanks. >-----Original Message----- >How can I copy my mail and calendar to CD so that I can >take my received and sent mail history to a new computer >with Outlook installed? Thanks. >. > All your data saves in C:\Documents and Settings\Username\Local Settings\Application Data\Microsoft\Outlook\archive.pst and C:\Documents and Settings\Evgeni\Local Settings\Application Data\Microsoft\Outlook\outlook.pst You can either install instan...

Copy picture ossice wizard
I have project 2007 standard edition, but the button is not working at all? Any suggestions Hi, The wizard is IMHO useless. Go to Roport, Copy Picture and do without the Wizard what millions have done before the Wizard existed. HTH -- Jan De Messemaeker Microsoft Project Most Valuable Professional +32 495 300 620 For availability check: http://users.online.be/prom-ade/Calendar.pdf "Enrique" <Enrique@discussions.microsoft.com> wrote in message news:72B5AA6C-67AE-468D-B6AE-FF16F52E57BD@microsoft.com... >I have project 2007 standard edition, but the bu...

Copy and paste versus copy and insert copied cells
What is the difference between these commands? Try them, it is pretty easy to see the difference -- Regards, Peo Sjoblom "Alana" <Alana@discussions.microsoft.com> wrote in message news:879FED29-5541-41B0-BB2C-7108D42ED593@microsoft.com... > What is the difference between these commands? ...

subtotal copy and paste
Hi I have used the subtotal option in Excel and this is fine. I have also collasped the list so only the subtotal for each category is visible. However I want to copy and paste this list (just the subtotal) into another sheet When I do this it expands and shows all the results. Is it possible to just copy the visible bit. I have looked in paste special but no luck Cheers Hager On Jan 21, 6:38=A0am, Hager <Ha...@discussions.microsoft.com> wrote: > Hi > > I have used the subtotal option in Excel and this is fine. I have also > collasped the list so only the...

Copy above fails one way, copy below fails another way
I have a table of blood pressure readings that looks something like this: A B C D E 11 12 Averages: 134 83 74 13 R# Date Sys Dia Pul 14 4 8/17/08 138 87 72 15 3 8/15/08 130 84 76 16 2 8/12/08 137 83 70 17 1 8/11/08 129 79 76 Cell A14 contains =A15+1 Cell C12 contains =AVERAGE(C14:C17) Cell D12 contains =AVERAGE(D14:D17) Cell E12 contains =AVERAGE(E14:E17) Every time I take a new reading, I want to add a row to the top of the table, between row 13 (the header) and row 14 (the previous top row). I want to push a...

limit number of rows 7 colloms in a worksheet
is there a way to limit or set the number of rows & collums in a worksheet ? thanks david --- Message posted from http://www.ExcelForum.com/ "davidbrowne17" <davidbrowne17.ya1sm@excelforum-nospam.com> wrote in message news:davidbrowne17.ya1sm@excelforum-nospam.com... > is there a way to limit or set the number of rows & collums in a > worksheet ? No. All worksheets have 256 columns by 65536 rows. You can hide unused rows/columns. But why bother? Hi David, Put this in the ThisWorkbook code module. Adjust to suit the area. Private Sub Workbook_Open() Wo...

Business Portal "Copy to Excel" not working in Query pages
Hi, I am using Business Portal 4.0. When browsing through one of the queries pages in Business Portal, i clicked "Copy to Excel" icon. I got an error saying "The Office Web Components (OWC) must be installed to copy results to Excel." at the bottom. I am using Office 2007 on my machine. I came to know that Microsoft Office Web Components will no longer be shipping in Microsoft Office. I tried installing Office 2003 Add-in: Office Web Components from http://www.microsoft.com/downloads/details.aspx?familyid=7287252C-402E-4F72-97A5-E0FD290D4B76&displaylang=en a...

Extra row in CTE
Hi, I have a table (#qed_missing_quarters) with the following rows in it: row_num quarter_end_date 1 2002-09-30 00:00:00.000 2 2002-12-31 00:00:00.000 3 2003-03-31 00:00:00.000 4 2003-06-30 00:00:00.000 5 2003-09-30 00:00:00.000 And I have the following code as a test to traverse across the table: ;WITH qed_missing_values(row_num, quarter_end_date) AS ( SELECT row_num AS [row_num], quarter_end_date AS [quarter_end_date] FROM #qed_missing_quarters WHERE row_num = 1 UNION ALL SELECT a.row_num + 1, a.quarter_end_date FROM #qed_missing_quarters AS a INNER JOIN ...

How can I get current cell row number
I need to reference the row value of the current cell in a worksheet function: = row() in VBA: activecell.row Hope this helps Rowan excelneophyte wrote: > I need to reference the row value of the current cell ...

Entering a formula into a screentip
I have a "quiz-style" spreadsheet. In it, I have included several CONCATENATE functions that takes their name which they entered at the beginging and a message and their score and puts it into a sentance. I have also used hyperlinks within my spreadsheet, I have been able to include the concatenate feature in these. It is possible to include any excel functions within this screentip? Thank's for your time Dan -- iPod's ROCK! By 'screentip' I assume you're talking about comments. There is no way to use Excel functions within a comment. -- Cordially, C...