Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This one gives appropriate answers for your example. </p> <p>Unfortunately, it has a few potentially fatal drawbacks, depending one's situation. For one, it causes a recalc, so the random numbers generated via <code>=RAND()</code> formulas in your sample are changed. </p> <p>The second drawback is that it modifies the worksheet in order to obtain the answers (it removes the modification that it makes, but still it gets modified). I can think of a few only partially helpful workarounds: (a) do this operation as seldom as needed and cache results for all columns, and (b) copy the table to a new workbook and run the routine (and delete the new workbook). While the latter would avoid the modification drawback, it still triggers a recalc for the original workbook (and otherwise has its own drawbacks). To add to that, copying the table to a new workbook looses the table/ListObject unless you copy the whole range (not just headers); then it also appears to promote the 4th column (non-calc consistent formulas) to being a calculated one. Sadly, this promotion also happens when copying the whole sheet.</p> <p>Well, FWIW:</p> <pre><code>Sub TestTable() Dim ans As String Let ans = "" Dim li As ListObject Set li = ActiveSheet.ListObjects(1) Dim rowCountBefore As Long Let rowCountBefore = li.ListRows.Count Dim lr As ListRow Set lr = Nothing On Error Resume Next Set lr = li.ListRows.Add(AlwaysInsert:=True) On Error GoTo 0 Dim rowCountAfter As Long Let rowCountAfter = li.ListRows.Count If Not (lr Is Nothing) And rowCountAfter = rowCountBefore + 1 Then Dim c As Long For c = 1 To li.DataBodyRange.Columns.Count Dim b As Boolean Let b = lr.Range.Cells(1, c).HasFormula ans = ans &amp; "col " &amp; c &amp; ": " &amp; b &amp; "; " Next li.ListRows(rowCountAfter).Delete End If MsgBox ans End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload