unknown_user1337
New Member
- Joined
- Sep 16, 2021
- Messages
- 3
- Office Version
- 2019
- Platform
- Windows
Having trouble finding the answer to this anywhere.. I need to add a Totals row to a dynamically created table with VBA, using a custom formula for the totals. Each row in the table has an "x" or is blank for each column, and I need to get the count of "x"'s for each column. What I have for code, after inserting data into a column:
This just returns an error for "Object variable or With block variable not set" on the last line above.. There is no documentation on how to use xlTotalsCalculationCustom, and I found the above solution buried somewhere in a stackoverflow answer.. So if this isn't right, what is??
VBA Code:
dest.ListObjects(destTbl).ListColumns(col).TotalsCalculation = xlTotalsCalculationCustom
dest.ListObjects(destTbl).ListColumns(col).Total.Formula = "=COUNTIF([" & col & "]," & Chr(34) & "x" & Chr(34) & ")"
This just returns an error for "Object variable or With block variable not set" on the last line above.. There is no documentation on how to use xlTotalsCalculationCustom, and I found the above solution buried somewhere in a stackoverflow answer.. So if this isn't right, what is??