Copy Ranges & Insert Rows In Table

Mar 27, 2008

I currently have a spreadsheet with 4 columns that represent Surface corridinates and Bottom Hole Corridnates.
Surface X, Surface Y, BH X, BH Y

We need to get the Bottom Hole XY to be directly under the Surface XY.

Attached is some sample Data and What I mocked up for a temp solution is in VBA Module2
RunAll it will complete 399 rows of data.

In Module1 I have the starting Code that I modeled off of a macro that I started to get the base code.

I just need this to loop till it has no more data to copy. and not use module2 at all.

I commented everything for my personal benifit and to help me understand the steps. also know its a monster right now but it does most of what I need it to do.

Sub CopyPasteBHXYs()
'Wrote Based on recorded macro
'Selects second data row and inserts a row above
Rows("4:4").Select
Selection.Insert Shift:=xlDown

'How to make it loop till the last data is reached?

End Sub

Side Note I'm finally taking a Excel VBA course Apr 8th and 9th.

View 5 Replies


ADVERTISEMENT

Copy Ranges From Matrix/Table

May 14, 2008

The "Sub Shortcut()" line is throwing the error.

Sub Shortcut()

Dim CellString As String

Dim BString As Boolean

Dim StrShort1 As String

StrShort1 = "Copy"

Sheets("Office - Generic").Activate

Range("A3:B14").Select

For Across = 1 To 12

View 5 Replies View Related

Insert Rows According Cell Value In Excel Table

Jun 7, 2013

I need a Module that allowed me when I run it to add Rows down according upper cells Value for Example;

Total
Names

2
Sami

5
Rami

Then after apply the Module I need like this;

Total
Names

2
Sami

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

View 4 Replies View Related

How To Copy Ranges Between Two Blank Rows

Aug 16, 2013

I have data in column A separated by blank rows. I want to copy ranges between two blank rows, and paste it to sheet named "mega" so that each range is in its own column.This is code I'm working now.

Code:

Sub QuickSet2()
Dim rng1 As Range
On Error Resume Next
Set rng1 = Cells.SpecialCells(xlCellTypeConstants).EntireRow
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1.Copy
Sheets("mega").Range("A1").End(xlRight).Offset(0, 1).Paste
Else
MsgBox "No constants found"
End If
End Sub

View 6 Replies View Related

Copy Over Rows To Sheets Based On Value According To Ranges

Oct 9, 2009

I am having trouble with IF, ELSE and END IF statements. In Column H I am trying to copy over rows to sheets based on value according to ranges. I am trying to use the code below but everything seems to get copied in to the first sheet "0-500". d= worksheet name.

View 6 Replies View Related

Macro Used To Insert Rows And Copy Formulas

Jul 13, 2009

I was searching through this site and found this macro ...

View 9 Replies View Related

Insert Rows And Copy Formula Cells

Dec 15, 2008

I am trying to finish off a form that allows a user to insert a row below the selected cell and copy the formula from the line above if one exists. The code inserts the line but does not copy the formulas if they exist.

Application. ScreenUpdating = False

Dim cRow
Dim j As Long

cRow = ActiveCell.Row

With ActiveCell
.EntireRow.Insert
End With

For j = 1 To Cells(1, 255).End(xlToLeft).Column
If Cells(cRow, j).HasFormula Then Cells(cRow, j).Copy Cells(cRow + 1, j)
Next j

View 9 Replies View Related

Insert Rows Macro & Copy Formats

Sep 25, 2006

I need to find a way to insert a row (preferably at the bottom of an existing list) that mirrors the formatting of the row above.

I have had a stab at this (see attached example file) but my solution requires the user to select the correct activecell before it works correctly

View 9 Replies View Related

Insert Rows By Condition & Copy Data Above

Mar 8, 2008

I deleted the data and made up some figures but kept the format to protect privacy. Highlighted blue and green because it's possible to have the same name have 2 different types. I put in dashed lines to more clearly divide months.

1. For each UNIQUE "Name" and "Type" add a new row starting from last entry
2. Copy A,B,C to new row
3. Copy LAST (most recent) "End Balance" from column "I" corresponding to last person
4. Copy column "I" formula into new role

So Name, ID#, type, column D and the formula in "I" (excluding "Name" and "Type" duplicates) should be added to the end of the sheet with their new row

Unsure if possible:

5. Make old amounts (columns D,F,H,I) not count towards the totals
6. Totals reflect new amounts only so values aren't counted multiple times

exampleforforum.xls

View 2 Replies View Related

Copy Data Into Multiple Rows Using Macros And Insert Zero

Apr 21, 2014

I'm new to Macros and below is my requirement.I need to split my data into multiple rows based on count and the first row should have the value but the other rows should have a value as zero.

Input

Count Value
1 400
2 101
3 300
4 450

Output

Count Value
1 400
2 101
20
3 300
3 0
3 0
4 450
4 0
4 0
4 0

View 4 Replies View Related

Insert Rows (and Copy Formulas) Using Command Button?

Feb 5, 2014

I have a simple command button in my worksheet that will insert a blank row and copy formatting, but not the formulas. How do I adjust the code so that the formulas are copied to the new blank row? This is currently what I have:

Private Sub CommandButton2_Click()
Sheets("WAWF Track").Range("A9").Select
ActiveCell.EntireRow.Insert Shift:=x1Down
End Sub

View 5 Replies View Related

Copy And Insert Rows From List To Ws Based On A Variable No

Dec 20, 2006

I have a bit of a curly one - I have a sheet with 9,000 records that I need to expand to 24,000 + on a separate sheet records using the following method:

1) Select and Copy entire row 2 from sheet(1)
2) Insert a number of new rows into sheet(2), based on the value of cells(2,8) or cell H2. Column H contains quantity values for each of the 9000 rows which are variable.
3) Repeat for row 3, copying and inserting into sheet(2) based on the value of the cell in H3.
4) loop through all records until complete

I have tried writing the code in VBA but am not even getting close!

View 9 Replies View Related

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 View Related

Copy Each Row Of Table & Repeat Rows X Times

Jan 24, 2009

I'm trying to transpose multiple values in Excel, but I'd also like to repeat row values for columns A through E. The attached file "Raw Data" worksheet shows what I start with, and the "End Result" worksheet shows what I'd like the end result to be.

View 3 Replies View Related

Copy Last X Rows Of Table & Set Page Breaks

Apr 16, 2008

I want to add a button on my Worksheet that will basically copy the last portion of the sheet (about 40 lines) and insert it at the bottom of the sheet (above the button). Each time the button is clicked, the last 40 lines will be copied and pasted. The script also sets the page break to the appropriate line. To achieve this, I've set up a hidden sheet that contains the line numbers and last page number. The script accrues these numbers every time the script runs.

I realise there may be a better way to do this, but at this point I'm trying to stick to what I know. I'm trying to use the function Row().Select, and I keep getting an Error 13. Example of my

Sub AddPageTest()
Sheets("SetPoint").Select
Dim CopyRows As String
CopyRows = Range("C13").Select
Dim InsertRow As String
InsertRow = Range("C14").Select
Dim SelRange As String
SelRange = Range("C12").Select
Dim LastPageNum As Integer
LastPageNum = Range("C5").Select
Dim NewLastPageNum As Integer
NewLastPageNum = LastPageNum + 1
Dim LastPageBreak As String
LastPageBreak = Range("C15").Select
Dim NextPageFirstRow As Integer
NextPageFirstRow = Range("C4").Select + 1...................

View 2 Replies View Related

Copy Rows From Multiple Different Ranges Within One Sheet To Another Sheet With And / Or Without VBA

May 17, 2014

The last few days I have been trying to figure this out with no luck whatsoever. I am using Excel 2010 32-bit with power query on a Windows 7 64-bit computer. I was going the use the html creator, but the dl link was down and I had to use screenshots.

I have a sheet titled "LeadSheet" that contains multiple data blocks of information (around 20). I have attached 2 examples of these data blocks and 2 examples of results needed below. I tried to create them so they would fill in the gaps of my explanation.

All of these data blocks are 7 columns wide and vary in row size from 10-250. The blocks of data all have titles on the 5th row, but are not headers, and then data beginning directly underneath. I hesitate calling them ranges because I only selected one data block as a range and named it "lead1" and then stopped not knowing if I was headed the right direction.

I first tried to create a table out of the range, but was unable to do so because the "Name" column is an array. The phone and address columns are populated by VLOOKUP. And although the images show the column names as the same for name, phone and address theyare actually different, like name-firm1, name-firm17,address-firmxyz, etc, etc. I not putting that in the images. The "Option 1", "Option 2", "Option 3" and "Option 4" columns are generated using a =IF formula.

I have another sheet titled "ResultsSheet".I'm needing a way or code to copy entire rows from the multiple data blocks/ranges in the "LeadSheet", and paste it in the"ResultsSheet", based on any value occurring in any of the"Option" columns within the individual data blocks/ranges along with appending the "Option #" title to either end of the copied row.

The "LeadSheet" is constantly being updated so information is being added and taken off all the time. That being said, is there anyway to make it update as soon as the "LeadSheet" does or on a timed interval so that the"ResultsSheet" is always up to date. And also prevent it from continuing to re-copy over duplicates of information that has not changed?

Ifthe "Option #" result is the exact same percentage then the order does not matter between them.

Ifwithin the same data block/range both "Option" columns have data it is usually because of some error and is most likely bad datathat does not need to be copied. i.e. "Steven Seagal". If that makes this task much more difficult I can live with it.

If within two or more different data blocks/ranges the same name and info appears that if fine because the "Option #" will always be different. i.e. "Chuck Norris".

I am also trying to make the "ResultSheet" ordered from largest percentage to lowest, but I assume that should be done once the data is on the "ResultsSheet". No headers or titles are necessary on the "ResultsSheet"

Data Block example 1:

Data Block example 2:

View 5 Replies View Related

Insert A Variable Number Of Rows And Copy And Paste From And To Variable Positions

Aug 8, 2009

On the attached Excel file, I have code that will insert a variable number of rows and copy and paste from and to variable positions. That all works fine when run from a command button, but when I try to run it from the Worksheet_Calculate by entering 1 in J1 or K1 (inrange cell is J1+K1 for testing purposes) the CommandButton1_Click sub runs continously until an error occurs.

View 4 Replies View Related

Insert Names For Ranges Using VBA?

Feb 24, 2013

i am trying to assign names to my ranges using VBA. i am doing it through the following but seems like it does not work.

Sub MakeName()
ActiveWorkbook.Names.Add Name:="ACCOUNT", RefersTo:="GL_Details!$J$2:INDEX(GL_Details!$J:$J,LastRow_GL)"
End Sub
>Workbook Defined NamesNameRefers To
ACCOUNT=GL_Details!$J$2:INDEX(GL_Details!$J:$J,LastRow_GL)
ACCOUNTING_PERIOD=GL_Details!$C$2:INDEX(GL_Details!$C:$C,LastRow_GL)
BUDGET_YEAR=Expenditure_Details!$BF$2:INDEX(Expenditure_Details!$BF:$BF,LastRow_Exp)

[Code] ........

View 2 Replies View Related

Excel 2010 :: Copy Table (listobject) INCLUDING Hidden / Filtered Rows

Nov 11, 2012

I'm trying to copy a whole bunch of tables with identical layout to a master table, so I can create a whole bunch of pivot tables that include data from ALL the various tables. The source tables MAY be filtered, and I can't work out how to copy them easily while also INCLUDING any hidden/filtered rows while at the same time leaving any filter settings on the source tables intact.

If I use something like range("Table1").Listobject.DataBodyRange.Copy then it only copies the VISIBLE rows.

But I want ALL rows to be copied to a master table.

1. I don't want to unfilter the sources tables, because users might still want the source tables to remain exactly as the user filtered them. (However, it doesn't matter if the DESTINATION list is filtered or not). I realise that I could copy the entire sheet to a temp sheet, then unfilter any tables on that sheet and THEN copy these to the master list. But wan't to know if there's a simpler way.

2. I DON'T want to use SQL to create a pivot table directly from the tables, because the tables will have further information added to them from time to time, and so if I use SQL to make a pivot directly from them, I'll have to recreate the pivot cache using that SQL query each time, which might muck up the settings in any existing pivot tables. I realise that I could use SQL to copy the data to a 'staging area', and just point the pivot table at that.

3. I can't use PowerPivot, because its not installed in this environment.

View 1 Replies View Related

Maro, Insert Rows Where Rows Determined By Number Of Carriage Returns

Feb 17, 2010

The best way to explain my problem is to look at the table below:

How it looks now: ApplePrice 1
Price 2
Price 3FruitDeliciousPearStore 1
Store 2FruitVery DeliciousHow I want it to look:ApplePrice 1FruitDeliciousApplePrice 2FruitDeliciousApplePrice 3FruitDeliciousPearStore 1FruitVery DeliciousPearStore 2FruitVery Delicious

View 9 Replies View Related

Macro To Split Rows Into Groups Of 5 And Insert 3 Blank Rows In Between

Feb 9, 2013

I would like to have my macro code search column A (supplier numbers) and split the rows into groups of rows of 5 or less and then insert 3 blank rows between each group of rows. The split needs to start on a new supplier number and cannot split a supplier number into two different groups. Here is a sample:

Supplier
Invoice Date
GL Date
Invoice Amt

[Code].....

View 1 Replies View Related

How To Dynamically Insert Rows With Duplicate Data Of Previous Rows

Oct 30, 2013

I have a spread sheet with values in the area of A1:H834

In column H, I have number values from 1-7.

Essentially that number value means that the values in the row are duplicate.

So, for example, if H2 has a value of 4, that means that $A$2:$G$2, really should have an additional 3 rows underneath with the EXACT same data in each cell, however, the way the sheet was created, was to remove the duplicate values and just indicate in column H, the number value of how many duplicates $A$2:$G$2 really is.

I need to unpackage this and create what it was originally. What type of formula can I use, to look at the value in H2, and then insert underneath that number of rowes with the exact same data as A2:G2 and do the same for the remainder of the table all the way down to A834:G834

View 1 Replies View Related

Macro To Insert New Rows Based On Commas In Previous Rows?

Mar 15, 2014

I'm a macro novice and have been trying to teach myself how to write the correct one for a task I need to do, but I cannot seem to get it right. Basically, I have bunch of data and for one of the variables, different values are separated by commas. What I want is to create a row copying the info below for each piece of data after the comma.

Sheet1

A
B
C
D

[Code].....

I suspect there is a fairly easy way to do this, but I cannot figure it out from searching the forums (or rather, I can't get it to work right).

View 6 Replies View Related

Insert Blanks Rows In Alternate Rows But Ignore If Already Blank

Jun 26, 2014

i have this code which inserts blank rows in alternate rows,

Code:
Sub insertrow()
' insertrow Macro
Application.ScreenUpdating = True
Dim count As Integer
Dim X As Integer
For count = 1 To 20
If activecell.Value "" Then
activecell.Offset(1, 0).Select

[code].....

what changes should i make in this code to insert rows only when ther are now blank rows. So first time i run, blank rows are already there, and when i update some data at the bottom and re-run it inserts blank rows again.

View 3 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

Pivot Table Ranges

Aug 4, 2007

I have just created a pivot table, however, i have just put the range to the cells that have data in them. The problem is, is that i want to make the cell range bigger, but the cells that i want to include do not have data YET, but will in the future. I have tried creating the pivot tables including the cells with no values, but it ends up puting 1 into the pivot tables cells for some reason.

View 9 Replies View Related

VLOOKUP Table Ranges

Nov 28, 2008

Is there anyway to, instead of indicating specific cells to be included in the range of a VLOOKUP table, designate the table range as whatever cells are selected in a spreadsheet.

The VLOOKUP formula is in a spreadsheet called "Template". The VLOOKUP table range will be in a spreadsheet called "Statement of Assets".

Here is the formula I have:

=VLOOKUP("Lookup Value",'Statement of Assets'!$A$122:$C$142,2,0)

But the row numbers in "$A$122:$C$142" is going to change depending on what plan number I am working on. Columns stay the same.

What I want is something like:

=VLOOKUP("Lookup Value",'Statement of Assets'!whichever cells are selected,2,0)

View 9 Replies View Related

Copy Ranges & Add Them To Other Ranges

Nov 1, 2006

In the attached file, I have variable range in column A:B, column C:D and in column E:F

I want a macro to do the following:

Start with sheet "A", select the available range in column A
then copy and paste in the sheet "B" but with all the cell values added with the value in H1.

Then in sheet A, simply copy the available range in column B and paste it in sheet B

Do the same until column F in sheet A. Pastespecial if it is odd column. simple past it is even column.

I know the macro code for the simple paste. But I am struggling with the paste special code.

View 9 Replies View Related

Indirect And Pivot Table Ranges

Oct 6, 2008

I have a sheet that is a download off of another system every month which means that the number of rows change from month to month. I have a pivot table of this data as well but I want it to change it's data range as it changes month to month. I have a Formula in cell C1 that defines the range, the formula is ="A5"&":"&"S"&B1 {B1 being the =COUNTA(A:A)}

Which yields A5:S31. Logically the way I thought this would work is by setting the Pivot Table range to : =Indirect(com.jdedwards.jas!$C$1) But this is not allowed as the range in a pivot table must be more than two rows. The second thing I tried was naming the range. I went to insert->Name->define and set the name to "Download" and the range to =Indirect(com.jdedwards.jas!$C$1). it didn't give me any errors but now I don't know how to set the pivot table to that named range and i don't even know if that is really going to work.

View 5 Replies View Related

Base Pivot Table Off Different Ranges

Dec 7, 2006

I need to read consantly changing shift time/ covered data from a Pivot Tables pivot chart and populate this data into number of shifts covered/ uncovered. This information is then put into a chart over a 24 hour period (from 0700 to 0700). I have been populating the data from the pivot chart by hand by referencing the number of shifts in the covered line and dragging it to correspond to the shift time data part. I then have to do this for the uncovered shifts. As the data in the pivot chart is constantly changing, i need to do this data ransfer 'automatically'. I have started to look at and learn VBA, but i am getting nowhere fast. I enclose a worksheet (blank) to give you an idea fo what i am trying to do.

View 4 Replies View Related







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