Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatic Sheet Name Read and Rename
I need to know if there is a way to write a macro or the code that will
open a file with the one worksheet that has a variable name and rename it to "Data". A program we pull trends with creates a .csv file with the worksheet that has the same name as the file name. I am trying to create a macro that will chart the data in the file. I want to be able to share this and would like to not have to constrict file names to match a referenced sheet name in a macro. I would rather rename the sheet when the file opens to match my referenced sheet name in my macro. Can this be done? Please answer this one. The last message I submitted has never been answered. That was over 2 months ago. Nobody would find it now. --- Message posted from http://www.ExcelForum.com/ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatic Sheet Name Read and Rename
Add these two lines of code to your macro right after opening the .csv file in you code.
****Assuming the file opens with only one tab**** activeTab = ActiveSheet.Name Sheets(activeTab).Name = "Data" ----- DataMan wrote: ----- I need to know if there is a way to write a macro or the code that will open a file with the one worksheet that has a variable name and rename it to "Data". A program we pull trends with creates a .csv file with the worksheet that has the same name as the file name. I am trying to create a macro that will chart the data in the file. I want to be able to share this and would like to not have to constrict file names to match a referenced sheet name in a macro. I would rather rename the sheet when the file opens to match my referenced sheet name in my macro. Can this be done? Please answer this one. The last message I submitted has never been answered. That was over 2 months ago. Nobody would find it now. --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatic Sheet Name Read and Rename
You could do:
worksheets(1).name = "data" But since there's only one worksheet in the workbook, couldn't your macro just refer to worksheets(1)? (might not work when the user adds a second sheet, though.) "DataMan <" wrote: I need to know if there is a way to write a macro or the code that will open a file with the one worksheet that has a variable name and rename it to "Data". A program we pull trends with creates a .csv file with the worksheet that has the same name as the file name. I am trying to create a macro that will chart the data in the file. I want to be able to share this and would like to not have to constrict file names to match a referenced sheet name in a macro. I would rather rename the sheet when the file opens to match my referenced sheet name in my macro. Can this be done? Please answer this one. The last message I submitted has never been answered. That was over 2 months ago. Nobody would find it now. --- Message posted from http://www.ExcelForum.com/ -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatic Sheet Name Read and Rename
Thanks for all your help. I used the first bit of code. It is just what
I needed. DataMan --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do i rename a sheet if the rename tab is inactive? | Excel Worksheet Functions | |||
macro to: Add new sheet, then rename new sheet with todays date | Excel Worksheet Functions | |||
Move data to new sheet - rename sheet based on criteria ? | Excel Discussion (Misc queries) | |||
Rename Sheet | Excel Discussion (Misc queries) | |||
how do I rename a sheet | New Users to Excel |