Results 1 to 22 of 22

Public or Private Variable

Threaded View

  1. #1
    Forum Contributor
    Join Date
    06-18-2010
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    546

    Public or Private Variable

    I have a module and in the Declaration Section I am declaring about 4 variables as Public. This works fine, allows me to pass variables to functions that I call etc etc. The problem that I have now is that I used the same variable name throughout multiple modules. For example in Module 1 I named a variable fileName1, well declaring it Public fileName1 in my Declaration Section is now throwing an ambiguous name detected compile error. To my understanding I need to keep the variable as Public in order to pass the data to the functions I am calling. Do I just need to go through and rename all my variables to different names so that no 2 variables share the same name regardless of what module they are in, or is there another workaround that can rectify this?

    I named the variable the same regardless of which module they were in for the fact that I plan to call the functions in numerous modules and just want to pass the variable fileName to the function and have the commands run! I am trying to cutdown on code writing, but I may have totally blown up my coding.
    Last edited by jo15765; 01-12-2012 at 02:47 PM.

Thread Information

Users Browsing this Thread

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

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