I am running Excel 2010 on a Windows 64-bit machine. I have a workbook with several worksheets, each of which contains data about a different folder on my file system. I have a general code module that contains VBA code that is used across all of the worksheets. It works fine. But I have been trying to create a function called FolderPath () in each of the worksheet code modules that returns the full path to the folder to which the worksheet pertains. My plan was that if I were on Sheet1, then invoking the FolderPath() method would activate the FolderPath() method in the Sheet1 worksheet code module, and invoking the FolderPath() method while I had Sheet2 active would activate the FolderPath() method in the Sheet2 worksheet code module, and so forth. So depending on which worksheet I had open I would get a value from the FolderPath() method that was appropriate for that worksheet. I have entered the FolderPath() method on each worksheet's code module by right-clicking on that worksheet's tab and selecting the Show Code entry from the context menu, so I'm pretty sure that I'm entering the code in the worksheet code module.
The problem is that when I am viewing any given worksheet and enter a reference to the worksheet function in any cell (e.g. =FolderPath()), I get a NAME! error. If I move the function to a general code module, Excel finds it with no problem, but it can't seem to find anything I put in the worksheet code module. I would have thought that the current worksheet's code module would be a place that Excel would automatically search when trying to locate a user-defined function, but that doesn't seem to be happening in my situation.
Is there something I need to do to get Excel to look in the worksheet code modules? Thank you.
The problem is that when I am viewing any given worksheet and enter a reference to the worksheet function in any cell (e.g. =FolderPath()), I get a NAME! error. If I move the function to a general code module, Excel finds it with no problem, but it can't seem to find anything I put in the worksheet code module. I would have thought that the current worksheet's code module would be a place that Excel would automatically search when trying to locate a user-defined function, but that doesn't seem to be happening in my situation.
Is there something I need to do to get Excel to look in the worksheet code modules? Thank you.