+ Reply to Thread
Results 1 to 3 of 3

VBA: Storing value/variable when a macro ends or workbook closed

  1. #1
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Question VBA: Storing value/variable when a macro ends or workbook closed

    Hi All

    I am trying to find a way to store a whole number in the workbook after the macro ends or workbook has been closed

    I found this post which gets me close, buy storing the value in the Excel Name object
    https://www.mrexcel.com/board/thread...manently.8711/

    But the value I wish to store & retrieve gets prefixed with an equals sign that I cant get rid of?

    MsgBox.png

    It also throws a run time error if I attempt to retrieve the version number & store it in an Integer variable (Run time error 13 - Type mismatch) but I do need to store it as a number so that I can do some math with it...

    Please Login or Register  to view this content.
    Any/all advice welcome
    Last edited by vwhite; 08-21-2020 at 06:07 AM.

  2. #2
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: VBA: Storing value/variable when a macro ends or workbook closed

    Sorry my bad. I wasn't reading the linked posted correctly. All sorted

  3. #3
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    467

    Re: VBA: Storing value/variable when a macro ends or workbook closed

    Hi

    For the benefit of others, if you named a cell as VersionNumber in your Excel 2010, then your posted code would display the address of that named cell,
    e.g. =Sheet1!$G$7

    If you want to display the contents of that named cell you would use..
    Please Login or Register  to view this content.
    zeddy

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Referring to closed workbook with variable file path
    By sean11118 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-22-2018, 02:04 PM
  2. [SOLVED] VBA Macro pull a certain cell in closed workbook and copy/paste into current workbook
    By Hoover5896 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2017, 01:36 AM
  3. Define variable as range in a closed workbook
    By puzzlelover22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-10-2016, 01:40 PM
  4. Vlookup From Closed Workbook with variable filename
    By wporter86 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-25-2013, 10:47 AM
  5. SUMPRODUCT to SUM variable range in closed workbook
    By opopanax666 in forum Excel General
    Replies: 2
    Last Post: 02-12-2010, 06:42 AM
  6. Storing VB Code in a variable withing a Macro
    By reclmaples in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-02-2009, 11:45 AM
  7. How to pass variable between closed workbook
    By hon123456 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-13-2006, 05:25 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1