+ Reply to Thread
Results 1 to 2 of 2

Variable Remains Empty after Macro Runs

  1. #1
    Registered User
    Join Date
    07-17-2014
    Location
    Arlington, VA
    MS-Off Ver
    2010
    Posts
    10

    Variable Remains Empty after Macro Runs

    Hi, I am having a specific issue as part of a much larger project. Quick background--this is for survey research data analysis. So, my data is constantly changing shape and size.

    I am trying to create a variable "Denominator" based off a specific location of a cell. I need to then use this variable "Denominator" a few times to determine the proportion or percentages of times a specific answer was provided for each questions.

    While I have two major issues right now, the first one to fix is the variable declaration problem.

    The code is below, and the variable declaration is bolded. Even after I run the code and hover over the variable name the pop-up box informs me that the variable is Empty. I believe, this explains why I keep receiving #NAME errors when I got to divide my total value by the Denominator variable.

    So, my question is what am I doing wrong?

    Please Login or Register  to view this content.
    I am open to suggestions for changing the formulation as a whole, I am still fairly new to VBA. So, if anyone thinks of an entirely different and better way to address the issue it is welcomed.

    Let me know if there is any additional information that I can provide. I am using excel 2010

    Thanks!!

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Variable Remains Empty after Macro Runs

    First you have declared your variable but you have not made it public so it is only available to its host macro.

    For other macros to be able to use it you need it to be public and at the top of a normal Macro Module.

    Ok assuming you declare your variables as Public, they will be erased each time you close your worksheet.

    So if you want to keep them then save them on a worksheet, either in a cell or as a name.

    click on Formula and then name manager to create your name.

    Save your workbook when you create your name and it will be saved too.

    Please Login or Register  to view this content.

    Once you have done that you can use denominator in your formulae.

    type this into a cell:

    Please Login or Register  to view this content.

+ 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. [SOLVED] If cell is empty in a variable range, stop macro and return error message
    By Andrei Kononenko in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-22-2019, 02:19 PM
  2. [SOLVED] Combo box remains empty due to missing rowsource in excel 2011
    By BobdeB in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-24-2014, 01:12 PM
  3. [SOLVED] Display current contents of a variable and see how it changes when code runs?
    By beaujolais44 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2013, 12:25 AM
  4. Macro with a variable that finds empty cell in a row
    By The student in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2011, 03:07 PM
  5. hourglass remains after macro runs???
    By Elizabeth in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-17-2005, 11:05 PM

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