admin管理员组文章数量:1130349
I've got a simple class thats executes SQL query, then fill array with query results, next convert it into Range, a finally there is a list object created:
Dim data() As Variant
...
ReDim data(0 To rowCount, 1 To colCount)
... populating data
Set rng = Range("A1:" & ColumnLetter(colCount) & CStr(rowCount + 1))
rng = data << Exception is raised here
Dim Tbl As ListObject
Set Tbl = ActiveSheet.ListObjects.Add(xlSrcRange, rng, , xlYes)
What I want to achieve is to enable, that query returns excel formula, for example, i can add to my select query:
SELECT
...
'=2*A1' AS COL1
And it works (=2*A1 is stupid/useless example, but i want to explain what i mean).
Now, i want to use structured references formulas, for example:
SELECT
...
T.SALE AS SALE,
'=[@Sale]/AGGREGATE(9;5;[Sale])' AS SALE_PART,"
...
but the problem is that [Sale] i a reference to table column - which doesn't exist yet, at a data population moment - so VBA throws exceptions - "Out of memory". I dont know why is about out of memory, but im sure its about cell with that formula (other cells before that one, are populated correctly).
So - the question is - can I temporary disable somehow formula validation (prevent error dialog) ? I could then reenable it, after creating a listobject, and then those problematic formulas will gone ([Sale] become a valid reference)
I think, the problem is connected with structured references. When I enter invalid formula like:
=xyz
there is no error dialog, but this formula is incorrect (#NAME?), but when i enter:
=[xyz]
there is a dialog box :(
I've got a simple class thats executes SQL query, then fill array with query results, next convert it into Range, a finally there is a list object created:
Dim data() As Variant
...
ReDim data(0 To rowCount, 1 To colCount)
... populating data
Set rng = Range("A1:" & ColumnLetter(colCount) & CStr(rowCount + 1))
rng = data << Exception is raised here
Dim Tbl As ListObject
Set Tbl = ActiveSheet.ListObjects.Add(xlSrcRange, rng, , xlYes)
What I want to achieve is to enable, that query returns excel formula, for example, i can add to my select query:
SELECT
...
'=2*A1' AS COL1
And it works (=2*A1 is stupid/useless example, but i want to explain what i mean).
Now, i want to use structured references formulas, for example:
SELECT
...
T.SALE AS SALE,
'=[@Sale]/AGGREGATE(9;5;[Sale])' AS SALE_PART,"
...
but the problem is that [Sale] i a reference to table column - which doesn't exist yet, at a data population moment - so VBA throws exceptions - "Out of memory". I dont know why is about out of memory, but im sure its about cell with that formula (other cells before that one, are populated correctly).
So - the question is - can I temporary disable somehow formula validation (prevent error dialog) ? I could then reenable it, after creating a listobject, and then those problematic formulas will gone ([Sale] become a valid reference)
I think, the problem is connected with structured references. When I enter invalid formula like:
=xyz
there is no error dialog, but this formula is incorrect (#NAME?), but when i enter:
=[xyz]
there is a dialog box :(
Share Improve this question asked Dec 15, 2024 at 21:23 b0bikb0bik 337 bronze badges1 Answer
Reset to default 0You could disable events with Application.EnableEvents = False, but instead of fudging and breaking things only to fix them later, why not do it right from the start? You seem to be complicating things unnecessarily. If you know you will be using a table later on, create it first without any data so you can reference it in your formulas properly.
I've got a simple class thats executes SQL query, then fill array with query results, next convert it into Range, a finally there is a list object created:
Dim data() As Variant
...
ReDim data(0 To rowCount, 1 To colCount)
... populating data
Set rng = Range("A1:" & ColumnLetter(colCount) & CStr(rowCount + 1))
rng = data << Exception is raised here
Dim Tbl As ListObject
Set Tbl = ActiveSheet.ListObjects.Add(xlSrcRange, rng, , xlYes)
What I want to achieve is to enable, that query returns excel formula, for example, i can add to my select query:
SELECT
...
'=2*A1' AS COL1
And it works (=2*A1 is stupid/useless example, but i want to explain what i mean).
Now, i want to use structured references formulas, for example:
SELECT
...
T.SALE AS SALE,
'=[@Sale]/AGGREGATE(9;5;[Sale])' AS SALE_PART,"
...
but the problem is that [Sale] i a reference to table column - which doesn't exist yet, at a data population moment - so VBA throws exceptions - "Out of memory". I dont know why is about out of memory, but im sure its about cell with that formula (other cells before that one, are populated correctly).
So - the question is - can I temporary disable somehow formula validation (prevent error dialog) ? I could then reenable it, after creating a listobject, and then those problematic formulas will gone ([Sale] become a valid reference)
I think, the problem is connected with structured references. When I enter invalid formula like:
=xyz
there is no error dialog, but this formula is incorrect (#NAME?), but when i enter:
=[xyz]
there is a dialog box :(
I've got a simple class thats executes SQL query, then fill array with query results, next convert it into Range, a finally there is a list object created:
Dim data() As Variant
...
ReDim data(0 To rowCount, 1 To colCount)
... populating data
Set rng = Range("A1:" & ColumnLetter(colCount) & CStr(rowCount + 1))
rng = data << Exception is raised here
Dim Tbl As ListObject
Set Tbl = ActiveSheet.ListObjects.Add(xlSrcRange, rng, , xlYes)
What I want to achieve is to enable, that query returns excel formula, for example, i can add to my select query:
SELECT
...
'=2*A1' AS COL1
And it works (=2*A1 is stupid/useless example, but i want to explain what i mean).
Now, i want to use structured references formulas, for example:
SELECT
...
T.SALE AS SALE,
'=[@Sale]/AGGREGATE(9;5;[Sale])' AS SALE_PART,"
...
but the problem is that [Sale] i a reference to table column - which doesn't exist yet, at a data population moment - so VBA throws exceptions - "Out of memory". I dont know why is about out of memory, but im sure its about cell with that formula (other cells before that one, are populated correctly).
So - the question is - can I temporary disable somehow formula validation (prevent error dialog) ? I could then reenable it, after creating a listobject, and then those problematic formulas will gone ([Sale] become a valid reference)
I think, the problem is connected with structured references. When I enter invalid formula like:
=xyz
there is no error dialog, but this formula is incorrect (#NAME?), but when i enter:
=[xyz]
there is a dialog box :(
Share Improve this question asked Dec 15, 2024 at 21:23 b0bikb0bik 337 bronze badges1 Answer
Reset to default 0You could disable events with Application.EnableEvents = False, but instead of fudging and breaking things only to fix them later, why not do it right from the start? You seem to be complicating things unnecessarily. If you know you will be using a table later on, create it first without any data so you can reference it in your formulas properly.
本文标签: EXCELVBAdisable quotInvalid formulaquot error dialogStack Overflow
版权声明:本文标题:Excel, VBA, disable "Invalid formula" error dialog - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1736007136a1377918.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论