Copy Selected Rows & Insert As Many Times As Rows Selected

Feb 6, 2008

The following code inserts a row below the selected row, and copies the formula of the row above into it.

Dim Rw As Integer
Rw = ActiveCell.Row
Selection.Insert Shift:=xlDown
Rows("" & Rw - 1 & ":" & Rw - 1 & "").Copy
Rows("" & Rw & ":" & Rw & "").Paste

However, I need to alter this to work for inserting more than one row at a time. ie. the user selects 'x' number of rows and 'x' rows are inserted below (in the same way 'Insert Row' works in Excel) and the row above the selection is copied down.

View 2 Replies


ADVERTISEMENT

Insert Two Columns For Selected Rows

Dec 6, 2008

I would like to select a number of columns and then run a macro that would insert two columns after each of the selected columns.

Or is there perhaps a faster way than using a macro?

View 9 Replies View Related

Copy Selected Rows To Another Sheet

Nov 30, 2006

I need to copy only user selected rows ( multiple) from one sheet to another. I see similar threads here but none that work with user selected rows.

View 4 Replies View Related

Copy Selected Cells/rows To Another Worksheet

Sep 6, 2008

I have set up the attached workbook to try to show the results that I need using the matching shaded cells in the worksheets.

The first part of the problem is that all data in columns A, B, C & H (Input1) needs to be copied to columns A, B, C & F in Input2 with the addition of a Zero value in columns D & E (sample data lines 1 - 3).

The second part of the problem is that all data in columns A, B, & F (Input2) where the cell in column C is equal to ZERO needs to be copied to columns A, B & C in Input 3 (sample data Lines 4 - 11).

It would also be useful to be able to copy data in columns A, B, & F (Input2) where the cell in column C is NOT equal to ZERO to columns A, B & C in Input 3 (sample data Lines 12 - 25). However, there will be often be more than value in column C (Input2) dictated by the date in Column A and number in Column B. The value in Column F (Input2) will always be the same for each of those rows, so it does not need to be duplicated in Column C (Input3).

This would have to be manually triggered by linking it to a button or menu item, not sure what would be the best option. As data is entered at various times of the week, the routine would either have to overwrite existing matching data or carry on from where it last finished!

View 9 Replies View Related

Copy All The Rows Until Row 37 And Move It One Row Up After The Selected Row Is Deleted

May 1, 2009

enables the user to select a row to delete. However, I need to do more than that. I need to be able to copy all the rows until row 37 and move it one row up after the selected row is deleted. Below is the code

View 3 Replies View Related

How To Select Cells Then Copy The Same Selected Rows In Another Row

Mar 26, 2013

I have some selected cells in column A, they are not consecutive. I would like to copy these values and then copy the same area but from a different column...

The code I have here is only working when I have a consecutive selection.

Code:
Set rng = Selection
fr = rng.Cells(1, 1).Row
lr = rng(rng.Count).Row
rng.Copy

View 5 Replies View Related

Copy Selected Cells Of Rows To Another Worksheet Based On A Condition

Feb 4, 2010

I am self-taught (arguably by a pretty shoddy teacher), and am determined to figure *some* of this stuff out. I need a code to look at the rows on one worksheet and based on the value of column A for each row, copy cells A through E in that row to cells A through E of a blank row on a corresponding worksheet. I found a code from another post that does just what I need it to with one small exception. The code was posted by DaveGuggs and is as follows:

View 2 Replies View Related

Copy Selected Data From Multiple Rows Into Separate Column In One New Row

Dec 1, 2013

ID Name QTY Price

1 John 5 15
2 Jim 6 20
3 Sue 10 200
4 Fred 12 125
1 Tim 7 26
4 Sue 10 100

I need macro to loop through all data and generate this table in another worksheet

1 John 5 15 Tim 7 26
2 Jim 6 20
3 Sue 10 200
4 Fred 12 125 Sue 10 100

Each data in a row in the new table will occupy a different cell.

View 3 Replies View Related

Copy Rows To New Sheet Based On Date Range Selected On A Form

May 8, 2009

This spreadsheet must perform calculations for every line since new items are added every day, so VBA is probably better than copying formulas down every line of the spreadsheet:

With the press of a button, I need to be able to select a range of dates and copy all lines within the range to a seperate sheet with the desired name under the same headings they currently reside under. I have included some modified code that is being used in another spreadsheet that was created for me, but I do not pretent to understand all of it and I no longer work with the creator of the spreadsheet. How do I use a button to open the form for date selections and entering the name of the new sheet, and then use the start button on the form to begin the matching and copying to a new sheet? If there is an easier way I am all for that too.

Also, I need to keep a total of all items by month as well as a monthly and annual average of the Total Item Value on the FY09 tab. This will eventually produce another sheet when a button is pressed to submit as a report. I think part of this answer is in using the MONTH(serial_number) function but I can only get this to work for a single cell. I need to search the entire Distribution 'D' column, match all the months to the FY09 tab to the respective month, and calculate the totals and averages. I think SUMIF may also be needed as well but need the MONTH(serial_number)to work first. If there is a way to code all of this in VBA that would be fine as well.

I have a pivot table on Sheet1 where I am trying to get the totals and averages described above but I am not sure it can do what I need. In column 'B' I need the total number of each item as well as the total number of all items. I tried various formats and adding the totals from the Totals tab but I have not figured it out.

View 7 Replies View Related

VBA Code To Copy Selected Multiple Columns To Multiple Rows In Excel

Mar 13, 2014

I want to to copy selected columns of sales data into rows organized by salesperson. I have just started out with VBA and find that I cannot do it myself.

My original data are in the form of the following:

invoice_no
product
sales
qty
total

[Code] .....

I want to display the data in another sheet in the following format:

sales_a
sales_b
sales_c
sales_d

[Code] ...........

View 2 Replies View Related

Copy Rows From Selected Sheet To New Sheet Based On Cell Value

Mar 27, 2008

i have a workbook that has a lot of sheets but i need to pull information from the one sheet "Veneer Log" i Need it to make new sheets with the same heading as on the "Veneer Log" (Rows 1 & 2) Sheet but it needs to be filtered by the "Product" Column (H) with a new sheet made for all the diffrent products i.e. Dimensional, Drywall, Corners - Thin V., Accents,..... so each product will have a new sheet with i am hoping someone can help me with this. This log changes Daily and it would be nice to have a sheet with only the same product on it to compare new orders so we can batch run. i hope i have given you enough information so someone can help me with this. i have attached a sample log the real log has about 10 worksheet for diffrent departments but i only need info from the Veneer Log Sheet.

View 14 Replies View Related

VBA To Copy Selected Rows In One Worksheet To The End Of A Table In Another Worksheet

Jun 22, 2006

I would like to be able to select several non-sequential rows in a worksheet called "Data" (using a check box or just entering a value in Column A) and then be able to press a Command button to copy the selected rows to another worksheet called "Estimate" at the bottom of a table, and delete the designators in Column A (i.e. deletes the value, or unchecks the boxes) so I can repeat the process again if needed.

View 7 Replies View Related

VBA Grouping Selected Rows

Feb 4, 2005

I have VBA code which selects a group of rows ranging between 1 row and 25 rows. I then want code to group the selected rows, however, the only code I know for grouping requires that I enter a specific starting and ending row (ExecuteExcel4Macro "SHOW.DETAIL(1,#,FALSE,#)").

Is there a way to have VBA group and hide a number or rows which is not known in advance and will change between daily executions of the code?

View 3 Replies View Related

Rows That Should Be Selected Aren't

Nov 18, 2009

What I have just tried is click "Reset" in the macro menu and resaved the macro and the workbook, and the proper max/min lines seem to be working. However, I still feel a little unstable about it and will watch it closely.

(My next questions is how to "freeze pane" a row of headings on the results page and post the results onto row 2 and downward *without* deleted row 1)
Hello,

Here is my hurdle.
Could someone please look at the code below and see if there is a hint why all rows from the top all the way down (from R5 to R604) are outlined, when the code should successfully be stating already that if a value in the S column (to the right) is the maximum, then only outline the rows that across the R rows (up and down) that are the MIN? Then, those red-outlined rows should successfully display on the Results page.

It worked before, but I do not know now why all of the rows on the Details page are now selected.

Is there some indicator in the code that says outline everything?

Issue 2:
When I try to run the macro from a button I created, a pop up message says that the file is already open. If I take that literally, it is indeed true because I want the file open. Apparently Excel thinks I have 2 files open with the same title. It wants me to either close one of them or rename them, according to the message. But there isn't another file open according to my searching. What does that message really hint for me to do?

View 12 Replies View Related

Delete Selected Row, And All Rows Below **

Aug 21, 2007

I have the following code, to find the 1st cell in column CG that contains a value of more than -200. I wish to delete the entire row that this resides on, and all rows below.

Range("CG2").Select
Do While Not Selection.Value > -200
Selection.Offset(1, 0).Select
Loop

View 4 Replies View Related

Delete Selected Rows

Aug 20, 2008

I'm trying to write a macro that if a 1 appears in column N (1 may appear more than once & the sheet continues forever) then to hide that particular row.

I will also then have a seperate macro to delete the entire rows where 1 appears.

View 9 Replies View Related

Transfer Selected Rows To Sheet

Aug 27, 2005

This works fine in detecting and copying the new material number accross to the master data sheet, but now i want it to copy the row in which the new material number is located as there is other information that goes with so it doesn't have to be manually typed in.

Dim MyValue As Variant
Dim FromSheet As Worksheet
Dim LookupColumn As Integer
Dim FromRow As Long
Dim FromColumn As Integer
'-
Dim ToSheet As Worksheet
Dim StartRow As Long
Dim LastRow As Long
Dim ActiveColumn As Integer
Dim ReturnColumnNumber
Dim ToRow As Long
Dim FoundCell As Object

'================================================= ============
'- MAIN ROUTINE
'================================================= ============
Sub DO_LOOKUP()
Application.Calculation = xlCalculationManual
'----------------------------------------------------------
'- LOOKUP SHEET [**AMEND AS REQUIRED**]
Set FromSheet = Workbooks("Book1.xls").Worksheets("MD")
LookupColumn = 2 ' look for match here
FromColumn = 2 ' return value from here
'-----------------------------------------------------------
'- ACTIVE SHEET
Set ToSheet = ActiveSheet
ActiveColumn = ActiveCell.Column................................

View 14 Replies View Related

Assemble Table In New W/s From Rows Selected In Other W/s

Aug 24, 2009

I think this might be a programming issue (not sure but I hope it can be solved).

I have three sheets, each containing a table. I'd like users to be able toggle or select rows from these tables for inclusion in a fourth table in a new worksheet.

Unfortunately I have zero knowledge of vba and 0.01 knowledge of macros. I'm attaching a sample of what I'm working with.

In the attached, the "price list," "likely to reference," and "optional" worksheets contain the source tables; I've added a column to the right of each called "include" (where I'd like a user to be able to select a desired row).

The "custom" worksheet is where I'd like an assembled worksheet to live.

View 12 Replies View Related

Print Selected Columns And Rows

Apr 27, 2013

I have a worksheet which contain a lot of data in it. I want only certain rows and columns to be printed when I click a button. Actually I am trying to print a report.

Suppose I have data across A10:M100. Lets say from columns A to D are permanent, if the cell colour of any cell from E to M is not Red then that is to be printed along with the contents in A to D. Since I have bunch of data in that sheet almost 10000 rows I separated data by giving them name. If it is possible to have an option to choose from before printing that would be much much better. Because even though there are many cells left uncoloured I don't want them to be in the print as they are belong to another table (I have given name for each table)

If all columns from E to M in row 20 are Red then that row should not appear in the print. If J20 is left uncoloured then it has to be printed along with the data from A20 to D20 ( which I said permanent). This colour I fill by a macro as when required only for the range E to M.

View 5 Replies View Related

Copying Selected Rows From One Workbook To Another

Sep 5, 2013

I have two workbooks say 'MASTER' & 'REVISED' in D:Office. The REVISED workbook contains certain rows colored in Yellow which contain the rectified data. How to copy those rows (rectified data rows of workbook REVISED) to the workbook MASTER in the same row number.

View 7 Replies View Related

Paste Also Rows That Selected From Listbox?

Jun 30, 2014

i would like to paste also the rows that selected from listbox i use a userform and also use multiselect listbox

Code:
Private Sub frmstartbtn_Click()
Dim lItem As Long
With Me.frmListBox1

[Code].....

View 1 Replies View Related

Macro To Delete Selected Rows

Feb 13, 2007

I can use Find to find all all my rows where there is an "X" in a cell, and delete all the rows found that way (even if they are separated by other rows) in one fell swoop -MANUALLY. I use Find after having limited the area to be searched with a named array (so other "X's" don't get involved).

But when I record a macro with all the same moves, NONE of the Find code appears in the macro AT ALL....just the delete command. Hello? Relative reference (on the record macro toolbar) seems to have no impact.

So....the mission here is to delete entire rows wherever an "X" has been entered in a certain cell to mark the row for deletion...and those X's get there either through a DV list OR by a cell below the DV copying down the X from the DV cell above.

This is so because sometimes rows are "sub" to the one above, and if the one above is marked for deletion, then so must be the rows sub to it.

I have found this seemingly simple for...next loop here on the board:

For a = 1 To 50
If Cells(a, 17) = "x" Then
Rows(a).Select
Selection.EntireRow.Delete
Next a

But the debugger reports a "next" without a "for" which is obviously there in dark blue as I suppose it should be.

If I could make this puppy work, I would sooner have it start from A2 and then go down from there to the last row -wherever that happens to be.

View 9 Replies View Related

Text To Column For Selected Rows

Sep 22, 2006

I’ve got a little problem with the text to column function.

I’ve got in column A critarias and if it is for example L it should run a surtain text to column code.

With Range("A1:A65536")
. AutoFilter Field:=1, Criteria1:="L"
Range("B1").Select
Selection.End(xlDown).Select
Range(Selection, Selection.End(xlDown)).TextToColumnS Destination:=Range("B2"), DataType:=xlFixedWidth, FieldInfo:= Array(Array(0, 1), Array(21, 1), Array(60, 1))
End With

With the Auto Filter some rows between 2 until 7624 are shown. But unfortunately the text to column code is used for every row between 2 and 7624. Does anyone know how to avoid it?

View 3 Replies View Related

Count Number Of Selected Rows

Nov 30, 2006

How do you count know the numbers of rows that has a selection

View 2 Replies View Related

Displaying Selected Rows In Excel Report?

Jul 18, 2013

This is easy enough, but I only want to have items listed if every field on the row is unique which I can do, but is it possible to only display these unique lines and have any lines that contain a duplicate not be shown as a blank or anything else?

View 1 Replies View Related

Hide Rows With Calculated Value Of 0 When New Department Is Selected

Jul 29, 2014

I have multiple departments and on each department we report the costs in four columns this month, budget, last month and last year. I have summed across the row to a hidden column and if the value is 0 I have a basic macro that "hides" the zero value rows. I understand I could further automate the process by having an "event" based in the spreadsheet which when the calculated values change the macro will run. This would mean when looking at the next department the zeros would automatically be hidden. I suspect I need a worksheet_calculate event but not been able to make it work.

View 2 Replies View Related

Print Selected & Multiple Rows To A Form

Jul 12, 2008

The file consists of 3 sheets:Orders,Order Form PO1 & Purchase Order. When I mark "x" in the row that I want to print, Order Form PO1 will be displayed with all data in the specific columns. However, it only allows me to select one row at a time. Now, I want to select multiple rows so that it will pass the data to the sheet Purchase Order.

View 13 Replies View Related

Function To Return # Of Column With Min Value In Selected Rows

Jun 22, 2006

For the sample data below, columns A – C contain survey response
data: 3, 6 and 9. I'm looking for advice on writing a function for column D
that would look at columns A – C and return the # of the column containing
the min value (e.g. A in this example).

A B C D
3 6 9 A

View 9 Replies View Related

Code To Delete Rows After Selected Cell

Sep 24, 2011

I've got a sheet that I build from a weekly sheet. I can have 30 to 60 rows, but I always have 10 to 20 rows left over with data in column C, none in A, my last code is "Range("A1").End(xlDown).Offset(1, 0).Select" which takes me to the last cell in column A. Any code that I can then delete say 20 rows after that? I tried one code, but it wanted to delete everything below the cell selected which ran & ran.

"-" are blanks. Range moves the selected cell to A4. I want to delete row selected + 19 more.

-|A|B|C|D
1|Y|2|9|J|
2|R|1|8|N|
3|G|4|7|N|
4|-|-|L|-|
5|-|-|L|-|

View 9 Replies View Related

IF / THEN Macro For Deleting Rows Except Selected One And Header

Sep 18, 2013

My excel contains first 5 rows of heading information and the rest of the rows contain the data. I want to select a specific row from the data and run a macro that would delete all other data containing rows.

This is what I have now:

Code:
Sub DelRows()
Rows(6 & ":" & ActiveCell.Row - 1).Delete
Rows(7 & ":" & 65000).Delete
End Sub

Everything is fine if I select any data row except the first one (R6). In that case, the macro doesn't work as it should, deleting a row from the heading ones.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved