4

Just like the title suggests, I am looking for a way to make a variable hold its value even after the Excel 2010 file containing the VBA code is closed, and retrieve it with its last value, the next time I open the file.

Edit: I am aware of the fact that I can store the data "externally" outside of the VBA code, either in a cell or in an external file or in another way. I am looking for a way involving ONLY the VBA code of the said Excel file. An answer indicating that this is impossible, is an acceptable answer too, of course.

  • Can't you just save it to a worksheet cell and retrieve it later? – douglaslps Oct 30 '13 at 10:36
  • 1
    @douglaslps I thought this would be implied by the question, but as I see it is probably not. I am looking for way, NOT involving storing the data I need in a cell. It's just a specific chucnk of data I do not want to be exposed on a cell in the open worksheet. – Noob Doob Oct 30 '13 at 10:37
  • What about saving the data to a file and retrieving it later? Refer to stackoverflow.com/questions/3085615/… – douglaslps Oct 30 '13 at 10:42
  • @douglaslps see edit. – Noob Doob Oct 30 '13 at 10:45
6

You could do something similar to:

ThisWorkbook.CustomDocumentProperties.Add _
Name:="Version Number", _
LinkToContent:=False, _
Type:=msoPropertyTypeNumber, _
Value:=7

As already discussed in here.

  • I will test it soon. – Noob Doob Oct 30 '13 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.