Create Row In ListObject Based On Number Of Selected Rows

Nov 11, 2012

If only 1 row is selected, it works fine, but if I've selected multiple rows it continues forever. I want to create a row in my ListObject based on the number of selected rows.

Code:
Sub CreateRow()
Dim rRow As Range

With ActiveSheet.ListObjects(1).ListRows
For Each rRow In Selection.Rows
.Add (rRow.Row - 2)
Next rRow
End With
End Sub

View 1 Replies


ADVERTISEMENT

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

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

Update Certain Rows Based On The Choice Selected From A Dropdown List

Jan 11, 2010

Is it possible to update certain rows only based on the choice selected from a dropdown list

I shall explain this scenario

I have attached a small excel sheet called TESTTHEM which i'm testing
and learning excel simultaneously. On the attached sheet

If i select a value in B4 as BusinessLogic, it should then lookup for relevent rows in MISC worksheet and copy C5:L5 from MISC worksheet and replace
the columns G4:P4

Is it possible to do this in excel?

View 13 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 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 Data From One Sheet To Another Automatically Based On Number Selected In Dropdown Control

Apr 25, 2013

I'm trying to copy data from one sheet to another sheet automatically based on a number selected in a drop down control.

I have used OFFSET to pull some information successfully from a list. This is easy for me to do with single entries and a list and has worked well. I want to do similar but with a dataset not just single cells.

But, I can't seem to make OFFSET work to show a set of data easily.

Perhaps I will need VB code to do so? Or there is another control I'm not aware of? I've done very little with VB.

I'll attach a sample file to try to show better what I'm trying to do.

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

Create Limited Number Of Columns/rows

Dec 11, 2008

is it possible to create or customize a worksheet with 30 columns and 120 rows only.

View 4 Replies View Related

Excel 2010 :: Extend Rows Based On The Number Of Rows In Another Sheet

Jun 16, 2014

calculate the number of full rows in one data base located on one sheet X to determine how many rows the macro needs to extend on sheet B (sheet B is made only of formulas for data interpretation in sheet A.

View 14 Replies View Related

Macro To Create New Tabs Based On A Contract Number

Apr 11, 2008

I work with contracts and have to report the sales for each contract by customer number, name, address, product code or sku, sales amount, quantity, and invoice date. Each contract number is associated with a product group and within that product group are a laundry list of product codes or skus.

Customers are often on different contracts for different products and may purchase some or all of the products on that contract. When I run a query from the system to extract this data, I get one sheet that contains 20,000 lines that have to then be sorted and seperated into different tabs based on the contract number. Keep in mind that a customer may be listed multiple times because each line in the query represents a product code and an invoice date.

I currently have a macro that will format the reporting such that it sorts the data, however, what it doesnt do is look for each instance of a particular contract number and separate it into different tabs.

So below are two examples: April and May 2008 Reports

April 2008 Report
Contract 1 contains 5,000 lines of data - extract into new tab
Contract 2 contains 5,000 lines of data - extract into new tab
Contract 3 contains 5,000 lines of data - extract into new tab
Contract 4 contains 5,000 lines of data - extract into new tab
Total lines = 20,000

May 2008 Report
Contract 1 contains 7,500 lines of data - extract into new tab
Contract 2 contains 5,500 lines of data - extract into new tab
Contract 3 contains 8,000 lines of data - extract into new tab
Contract 4 contains 9,000 lines of data - extract into new tab
Total lines = 30,000

So for the April Example, I would like excel to take this one list and break into 4 new tabs based on the contract number and carry over all of the data into that tab.

Where this may become difficult is that there may be more lines of data one month and fewer another. Im not sure if there is a function that will tell excel to stop when it reaches the last line for one contract number and to start a new tab for the next contract number. (see the month of May example)

View 9 Replies View Related

Create Duplicate Rows Based On Value In A Column?

Feb 6, 2010

I have a worksheet with two columns and a few hundred lines. One has titles and the other integers indicating how many times the title needs to be copied to another worksheet or text file.

Existing Worksheet (Input)
TitleA1
TitleB6
TitleC4
TitleD3

Desired Output (Worksheet or Text File) [The entire row, including the integer could be copied as well, if it is easier.]
TitleA
TitleB
TitleB
TitleB
TitleB
TitleB
TitleB
TitleC
TitleC
TitleC
TitleC
TitleD
TitleD
TitleD

View 7 Replies View Related

Create Duplicate Rows Based On Value In A Column

Feb 6, 2010

I need a VBA/macro very similar to several I have seen posted here. I have a worksheet with two columns and a few hundred lines. One has titles and the other integers indicating how many times the title needs to be copied to another worksheet or text file.

Existing Worksheet (Input)
TitleA1
TitleB6
TitleC4
TitleD3

Desired Output (Worksheet or Text File) [The entire row, including the integer could be copied as well, if it is easier.]
TitleA
TitleB
TitleB
TitleB
TitleB
TitleB
TitleB..............

View 2 Replies View Related

Create Range Based On Starting Cell Plus A Number Sent To Formula

Mar 13, 2014

I'm using the VBA code below for a piece of code.

[Code] .....

However, I want to use this same function in another place, without the limit set on the cells that will be cleared.

What I would like to do is send the formula the cell to start at (E14), offset that by one column, and then send a number of rows. With that, create the range to be cleared.

Something like:

[Code] .....

View 3 Replies View Related

Excel 2013 :: Create New Values Based On Number In One Cell?

Jul 21, 2014

I have the following data set with about 500 rows. It has one large value in column A, followed by a number between 1 and 24 in column B.

I am trying in Excel 2013 to develop a formula that will: divide A by the value in cell BPlace in cell C, D, E, F... the result of this division, where the number of times the value is repeated depends on the value in B. E.g.

Example of source values/data set:
A
B

18504
18

2011
2

23694
24

(about 500 rows more)

An example of the output result that I am looking for:
A
B
C
D
E

2011
2
1,005.5
1,005.5

In above example, the value in column B is 2, so the result of the division of value A with value B is repeated twice. In case value B would be 18, the value would be repeated 18 times...

I have been trying to do this in Excel for more than 2 hours, but I did not manage to complete it.

View 2 Replies View Related

Create Order Form That Inserts Rows Based On Value In Column

Apr 11, 2014

I'm trying to make an order form that is based off of a price list. Basically there will be 200 items or so someone can just enter the quantity they want into a column. I would then like another sheet on the workbook to auto-populate all of the fields available. The thing I'm having trouble with is I don't want the finished form to be as long as the price list with blank rows in-between. I've been reading up to make a macro work for this, but have had no success.

View 3 Replies View Related

Looping Through ListObject?

Apr 11, 2014

I am looking to create a loop in a ListObject object that does calculations depending on the value of the current certain row in a column. This is the code I have so far:

[Code]....

I am having trouble with the loop; as you can see, the nested for loop will go through all the 'weight' in the column before going to the next 'grade'. I just want the loop to reference the same 'weight' that the 'grade' is on and move on. But I am not sure how to reference each 'weight' as I progress through each 'grade' in parallel.

I am aware that I can do this with regular cell references:

[Code] ......

but I am more interested in learning on how to work with the ListObject class.

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

Value Of First Column In Active Row In ListObject

Feb 27, 2012

I want the value of the first column in the active row in a ListObject. I've tried

Code:

MsgBox ActiveCell.ListObject.ListRows(ActiveCell.Row).Range.Address,

but don't know how to refer to the first column in this row. I've also tried

Code:

MsgBox ActiveCell.ListObject.ListRows(ActiveCell.Row).ListColumns(1).Range.Value ,

but it returns an error message.

View 3 Replies View Related

Macro To Select First Row Of ListObject

Jul 31, 2012

I'd like to create a macro that will do this trick:

Only activates when I select a cell in a ListObject.When activated: selects the entire first row of that Listobject,and only selects the cells in the range of that Listobject.

Because I have more Listobjects, I'd like to have one code which works for all of them.

View 6 Replies View Related

Sort Table ListObject 2007

May 16, 2008

i am trying to sort a table in Excel 2007. I am getting a syntax error that i don't understand as the arguments for the sort method are optional.

Sub SortTable()
Dim table As ListObject
Set table = ActiveSheet.ListObjects("Table_INDEX")
Dim columnToSortBy As Range
Set columnToSortBy = table.ListColumns(1).Range
With table
.Sort.SortFields.Clear
.Sort.SortFields.Add (columnToSortBy, xlAscending)
With .Sort
. Header = xlYes
.MatchCase = False
.Apply
End With
End With
End Sub

View 3 Replies View Related

Excel 2007 :: How To Use Or Delete A Table (ListObject)

Jan 11, 2012

I am using Excel 2007 and I created a table (i.e., listobject) using the macro recorder as follows:

Code:
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$3:$J$50"), , xlYes).Name = "MyData"
Questions:

1. How do I delete this table via VBA?

2. How would I check to see if this table already exists so it follows this logic:

If "table does not exists" then
'create it (using the line of code above)
End If

View 3 Replies View Related

Autofill Rows Based On Number

Jul 26, 2012

I have wookbook with a lot of sheets on it

The first sheet to be filled is called "Local Info"

In this sheet in the Active Cell "G7" the user must register a number between 0-500

This number must affect my next sheet called Competence Map Autofilling rows 7+8 from Columns A to AM

So If for example I put 83 in "local INFO" G7.

I will get 172 rows with text (the first 6 Headers) the 7-8 original and from 9-172 filled with the information given.

View 3 Replies View Related

Function To Sum Number Of Rows Based On Variable

Jun 23, 2014

As you can see in the attached excel doc, I have calculated a column for "Number of Claims Per week" and also "Dollar amount Per claim". This was done using VLOOKUP and distributions. That is not the issue.

The issue I am having is creating the "TOTAL" for the week. So for example, if week one generates 4 claims, I need to be able to add up claim amount #1-#4.

It seems as though this would be a basic function, but I can seem to find a way to add up a certain number of cells, based on a variable generated from a random number.

If you take a look a my excel sheet, I am trying to solve for the "Claim Total" column on the far right. This column should be the sum of (Number of claims * The individual amount per claim). Note that if there is 4 claims in that week, I would have to add up claim 1-4 to get that weeks total.

Question2.xlsx‎

View 9 Replies View Related

Copy Cells Down Based On Number Of Rows

May 11, 2009

My worksheet has data in column A. A formula is placed in cell B2 (col headers are in the first row). What is the code to copy it down so it coincides with the rows in Column A? If I use the following:

View 6 Replies View Related

Duplicate Rows Based On Number In Text

Aug 14, 2007

I have a problem of having to repeatedly copy and paste a series of data based on the number of occurrences in each row of data series. For instance:

[Road Name] [Building Name] [No. of occurrence]
(1) [Scotts Rd] [Tangs Building] [38]
(2) [Orchard Rd] [ABC Building] [3]
(3) [French Rd] [DB Bank] [1]

I will need to duplicate (1) 38 times with the location name and building name. Similarly, I need to duplicate (2) 3 times. How can I simplify it programmatically?

View 3 Replies View Related

Insert Rows Based On Number Of Columns Used

Jan 31, 2008

I have a spreadsheet which contains data needing to be re-formatted into a suitable format for my database. So far I have been doing this by hand, but want to make it quicker as I have over 2000 lines to sort out. I am trying to write a macro that determines whether there is data in the column next to the active one (D2), and if there is counts how many columns there is data in. Once it has done this it needs to insert the same number of rows as there are columns, then copy the column data and transpose it into the empty rows. My macro seems to work at first, but it exits after around the 4th row, but I can't work out why.

Sub split_For_Database()
Dim No_Of_Cells As Integer
Dim Start_Cell As Range
Dim Cell As Range
Dim LastRow As Range
Dim i As Integer
Dim lRows As Long
Set LastRow = Range("C65536").End(xlUp)
i = 0
Set Start_Cell = Range("C2")
Set Cell = Start_Cell
Do While Start_Cell.Address <= LastRow.Address
Do While Cell.Offset(0, 1) > 0
i = i + 1
Set Cell = Cell.Offset(0, 1)
Loop...................................

View 8 Replies View Related

Insert Number Of Rows Based On User Input

Apr 23, 2014

I have an excel sheet that I've automated for my shop ... Basically it copies a set of rows from one sheet, asks for which cell you want to start the paste at, then pastes it... Here's what I have so far:

[Code] .....

So I tried to use a variation of strReturn to indicate number of rows wanted but that didn't work ... Basically I'm going to create the "data" to include 50 rows, but have it selectable for the user to say they only want 5, 7 or 29 rows ...

View 2 Replies View Related

Macro To Add Additional New Rows Based On Number In A Call?

Jun 3, 2014

create a macro that will insert a certain number of blank rows to my spread sheet. The number of rows is determined by the #of tasks calculated for that day and is in column B. For example if in column A the date is 01-07-14 and in column B it has 7, I would like 7 rows inserted with the date in column A to remain the same in all 7 rows. Ideally I would like to use this macro for every row, so if the next row down has 02-07-14 and 6, I would like it to add 6 new rows with the same date.

I have attached a copy of the spread sheet for reference.

View 4 Replies View Related

Insert Number Of Rows Based On Cell Values?

Feb 20, 2009

Column B contains geographical Areas. Column C contains a list of business departments.

North Env
North Env
North Ops
North Sales
North Sales
North Sales
South Env
South Maint
South Ops
South Sales
South Sales
South Sales

Etc.

The values and number of these departments will vary. I want to insert lines to sum the totals at the bottom of each geographic area based on the number of different departments. So, for this example, for the North three lines would be inserted. For the South, 4 lines would be inserted.

View 4 Replies View Related







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