Dictionary of log of variables names and values
I apologize for the question that seems to be quite simple but for which I haven't been able to find an answer online.
I am interested in retrieving variables' names and values that were used before Excel crashes.
According to Write contents of immediate window to a text file it is possible to write a log to a text file.
According to reading and writing a csv file using FileSystemObject it is also possible to create a CSV file
Suppose that at one point
myVariable = "Hello"
and then later in the macro
myVariable = "World"
My question is:
How can I format this log as a two column table where the first column would be the list of the names of the variables that have been specified (here myVariable) and the second column would only be the latest value of the variables in use (here "World").
The rows of the table would be incremented as new variables are defined and the second column of the table would be overwritten as the values of those variables change.
excel vba
add a comment |
I apologize for the question that seems to be quite simple but for which I haven't been able to find an answer online.
I am interested in retrieving variables' names and values that were used before Excel crashes.
According to Write contents of immediate window to a text file it is possible to write a log to a text file.
According to reading and writing a csv file using FileSystemObject it is also possible to create a CSV file
Suppose that at one point
myVariable = "Hello"
and then later in the macro
myVariable = "World"
My question is:
How can I format this log as a two column table where the first column would be the list of the names of the variables that have been specified (here myVariable) and the second column would only be the latest value of the variables in use (here "World").
The rows of the table would be incremented as new variables are defined and the second column of the table would be overwritten as the values of those variables change.
excel vba
Apologies I meant creating a CSV file. It seems that it is possible according to stackoverflow.com/questions/9442215/… What i can't figure out is how to ask Excel for a table of varName=varValue in a way that overwrites the rows of this table as the values evolve during the macro.
– user1627466
Nov 20 '18 at 11:40
Excel does not do that. At each point in your program where you change a variable's value, you also put aPrint
statement. Tedious manual job, no magic. If is much simpler if you just dump each new value as its own line and then when you read the log later, you only respect the latest value.
– GSerg
Nov 21 '18 at 10:11
Thanks, this is counterintuitive. I would have thought Excel was aware of the changes made as one can see the value of a variable when one hovers above its name.
– user1627466
Nov 21 '18 at 10:17
add a comment |
I apologize for the question that seems to be quite simple but for which I haven't been able to find an answer online.
I am interested in retrieving variables' names and values that were used before Excel crashes.
According to Write contents of immediate window to a text file it is possible to write a log to a text file.
According to reading and writing a csv file using FileSystemObject it is also possible to create a CSV file
Suppose that at one point
myVariable = "Hello"
and then later in the macro
myVariable = "World"
My question is:
How can I format this log as a two column table where the first column would be the list of the names of the variables that have been specified (here myVariable) and the second column would only be the latest value of the variables in use (here "World").
The rows of the table would be incremented as new variables are defined and the second column of the table would be overwritten as the values of those variables change.
excel vba
I apologize for the question that seems to be quite simple but for which I haven't been able to find an answer online.
I am interested in retrieving variables' names and values that were used before Excel crashes.
According to Write contents of immediate window to a text file it is possible to write a log to a text file.
According to reading and writing a csv file using FileSystemObject it is also possible to create a CSV file
Suppose that at one point
myVariable = "Hello"
and then later in the macro
myVariable = "World"
My question is:
How can I format this log as a two column table where the first column would be the list of the names of the variables that have been specified (here myVariable) and the second column would only be the latest value of the variables in use (here "World").
The rows of the table would be incremented as new variables are defined and the second column of the table would be overwritten as the values of those variables change.
excel vba
excel vba
edited Nov 21 '18 at 10:08
asked Nov 19 '18 at 14:19
user1627466
142210
142210
Apologies I meant creating a CSV file. It seems that it is possible according to stackoverflow.com/questions/9442215/… What i can't figure out is how to ask Excel for a table of varName=varValue in a way that overwrites the rows of this table as the values evolve during the macro.
– user1627466
Nov 20 '18 at 11:40
Excel does not do that. At each point in your program where you change a variable's value, you also put aPrint
statement. Tedious manual job, no magic. If is much simpler if you just dump each new value as its own line and then when you read the log later, you only respect the latest value.
– GSerg
Nov 21 '18 at 10:11
Thanks, this is counterintuitive. I would have thought Excel was aware of the changes made as one can see the value of a variable when one hovers above its name.
– user1627466
Nov 21 '18 at 10:17
add a comment |
Apologies I meant creating a CSV file. It seems that it is possible according to stackoverflow.com/questions/9442215/… What i can't figure out is how to ask Excel for a table of varName=varValue in a way that overwrites the rows of this table as the values evolve during the macro.
– user1627466
Nov 20 '18 at 11:40
Excel does not do that. At each point in your program where you change a variable's value, you also put aPrint
statement. Tedious manual job, no magic. If is much simpler if you just dump each new value as its own line and then when you read the log later, you only respect the latest value.
– GSerg
Nov 21 '18 at 10:11
Thanks, this is counterintuitive. I would have thought Excel was aware of the changes made as one can see the value of a variable when one hovers above its name.
– user1627466
Nov 21 '18 at 10:17
Apologies I meant creating a CSV file. It seems that it is possible according to stackoverflow.com/questions/9442215/… What i can't figure out is how to ask Excel for a table of varName=varValue in a way that overwrites the rows of this table as the values evolve during the macro.
– user1627466
Nov 20 '18 at 11:40
Apologies I meant creating a CSV file. It seems that it is possible according to stackoverflow.com/questions/9442215/… What i can't figure out is how to ask Excel for a table of varName=varValue in a way that overwrites the rows of this table as the values evolve during the macro.
– user1627466
Nov 20 '18 at 11:40
Excel does not do that. At each point in your program where you change a variable's value, you also put a
Print
statement. Tedious manual job, no magic. If is much simpler if you just dump each new value as its own line and then when you read the log later, you only respect the latest value.– GSerg
Nov 21 '18 at 10:11
Excel does not do that. At each point in your program where you change a variable's value, you also put a
Print
statement. Tedious manual job, no magic. If is much simpler if you just dump each new value as its own line and then when you read the log later, you only respect the latest value.– GSerg
Nov 21 '18 at 10:11
Thanks, this is counterintuitive. I would have thought Excel was aware of the changes made as one can see the value of a variable when one hovers above its name.
– user1627466
Nov 21 '18 at 10:17
Thanks, this is counterintuitive. I would have thought Excel was aware of the changes made as one can see the value of a variable when one hovers above its name.
– user1627466
Nov 21 '18 at 10:17
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376596%2fdictionary-of-log-of-variables-names-and-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376596%2fdictionary-of-log-of-variables-names-and-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Apologies I meant creating a CSV file. It seems that it is possible according to stackoverflow.com/questions/9442215/… What i can't figure out is how to ask Excel for a table of varName=varValue in a way that overwrites the rows of this table as the values evolve during the macro.
– user1627466
Nov 20 '18 at 11:40
Excel does not do that. At each point in your program where you change a variable's value, you also put a
Print
statement. Tedious manual job, no magic. If is much simpler if you just dump each new value as its own line and then when you read the log later, you only respect the latest value.– GSerg
Nov 21 '18 at 10:11
Thanks, this is counterintuitive. I would have thought Excel was aware of the changes made as one can see the value of a variable when one hovers above its name.
– user1627466
Nov 21 '18 at 10:17