listobject

Pasting an array of values over a ListObject (Excel table) destroys the Listobject

非 Y 不嫁゛ 提交于 2019-12-06 08:23:40
In one of my worksheets, I have a Private Sub BuggingVba() That should replace the data in a table with an array of values Dim MyTable As ListObject, myData() As Variant Set MyTable = Me.ListObjects(1) myData = collectMyData ' a function defined somewhere else in my workbook It is probably irrelevant, but before doing so, I resize the list object (I expand line by line because if I do it at once, I overwrite what is below my table instead of schifting it.) Dim current As Integer, required As Integer, saldo As Integer current = MyTable.DataBodyRange.Rows.Count required = UBound(sourceData, 1) -

How to read formulas of Calculated Columns in an Excel Table/ListObject without any data rows

牧云@^-^@ 提交于 2019-12-05 14:49:23
I have a ListObject with an external query as the data source, which returns 18 columns. The ListObject has previously had an additional 4 calculated columns added. Right now, the ListObject has 0 data rows, however, while there are 0 data rows, I don't seem to be able to read the pre-defined formulas of the calculated columns. If I refresh the data source, and the data source returns at least 1 row, then the formulas for the calculated columns become readable. Likewise, if I manually enter data in one of the non-calculated columns, so that there is at least one row, then the calculated column

Excel 2010, VBA and ListObjects subtotals not updating on Table changes

最后都变了- 提交于 2019-12-05 05:49:27
So, having this structure (starting at A1 - show snippet > run): table { border-color: #BBB; border-width: 0px 0px 1px 1px; border-style: dotted; } body { font: 12px Arial, Tahoma, Helvetica, FreeSans, sans-serif; color: #333; } td { border-color: #BBB; border-width: 1px 1px 0px 0px; border-style: dotted; padding: 3px; } <table> <tbody> <tr> <th></th> <th>A</th> <th>B</th> <th>C</th> <th>D</th> </tr> <tr> <td>1</td> <td>Title 1</td> <td>Title 2</td> <td>Title 3</td> <td>Title 4</td> </tr> <tr> <td>2</td> <td>GH</td> <td>1</td> <td>434</td> <td>4</td> </tr> <tr> <td>3</td> <td>TH</td> <td>3</td

Trouble pasting row to table

ⅰ亾dé卋堺 提交于 2019-12-02 09:36:58
For every cell that is not blank in column "Transition" of table "TableQueue", I want to: 1)Copy from table "TableQueue" the entire table row that contains that cell, 2)Paste that row to the bottom of table "TableNPD", 3)Delete the row from table "TableQueue" I've gotten everything except the copy/paste/delete to work. See my note halfway down the code below to see where my problem begins. I am new to vba and, although I can find plenty of info on copying and pasting to the bottom of a table, its all slightly different from each other and different from how I've already set up the top half of

Excel VBA ListRows.Add Fails

岁酱吖の 提交于 2019-11-29 18:04:15
I'm probably missing something simple, but ListRows.Add is giving me grief. Here's the function: Sub addEmployee(employeeName As String, tableToAddTo As ListObject) Dim newRow As ListRow Set newRow = tableToAddTo.ListRows.Add() newRow.Range.Cells(1, 1).Value = employeeName tableToAddTo.Sort.Apply End Sub In most cases, this works fine. However, whenever the function runs on a certain table in my worksheet, the lines following the call to ListRows.Add are never executed (at least that's what the debugger indicates) and the row does not get added to the table. Any thoughts/ideas? UPDATE: Here's

Add/Modify/delete calculated column formula in Excel Listobject/Table via VBA

两盒软妹~` 提交于 2019-11-28 00:14:34
If I manually enter a formula into a column in an Excel table (i.e. ListObject), AutoCorrect applies this formula to the whole column. Is there any way to control the this behavior via VBA, i.e. can I somehow modify/delete/add this formula? I know I can simply change the formula of the ListObject.ListColumns(1).DataBodyRange object - but this will overwrite any manually values entered before - while changing the formula in the UI will leave this untouched... Thanks to Doug's and bonCodigos comments/answers, I found the simple answer: ListObject.ListColumns("Column name").DataBodyRange

How do I reference tables in Excel vba?

风流意气都作罢 提交于 2019-11-27 13:30:28
Is it possible in Excel VBA to reference a named table? Hypothetically this could be... Sheets("Sheet1").Table("A_Table").Select I have seen some mention of tables being a list object but I'm not sure if that is the same thing... Bgvv1983 Maybe this can help you Creating a table Converting a range to a table starts with the same code as in Excel 2003 (as described in this answer ): Sub CreateTable() ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$1:$D$16"), , xlYes).Name = _ "Table1" 'No go in 2003 ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleLight2" End Sub The OP asked, is it

How do I reference tables in Excel vba?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 16:25:55
问题 Is it possible in Excel VBA to reference a named table? Hypothetically this could be... Sheets("Sheet1").Table("A_Table").Select I have seen some mention of tables being a list object but I'm not sure if that is the same thing... 回答1: Maybe this can help you Creating a table Converting a range to a table starts with the same code as in Excel 2003 (as described in this answer): Sub CreateTable() ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$1:$D$16"), , xlYes).Name = _ "Table1" 'No go in