I am writing a macro to preform processes on an excel spreadsheet. I'm trying to use the file name string to input into cells. I have tried the following code:
The workbook I am working out of is called "2008 02.xlsx", but when I run this code the variable "MyName" returns "PERSONAL.X LS". It my be something about the version of excel I am using (2003 version). When I choose Tools/Macro/Record New Macro in excel, there is a drop down called "Store macro in:" and has three options: "Personal Macro Workbook", "New Workbook", and "This Workbook". I choose "Personal Macro Workbook" so I can use this macro on multiple workbooks. If I were to use "This workbook" I wouldn't be able to use it on any other workbook. I feel like this choice is why I cannot return "2008 02" when I run this code. Does anyone have an insight on what code to use to get "2008 02.xlsx" instead of "PERSONAL.X LS"?
Code:
MyName = ThisWorkbook.Name
Comment