Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i rename a sheet if the rename tab is inactive? Nelson Excel Worksheet Functions 1 March 3rd 10 10:28 AM
macro to: Add new sheet, then rename new sheet with todays date Paul Excel Worksheet Functions 3 September 29th 07 03:17 AM
Move data to new sheet - rename sheet based on criteria ? [email protected] Excel Discussion (Misc queries) 7 May 16th 07 10:22 PM
Rename Sheet Linda@VZ Excel Discussion (Misc queries) 1 November 2nd 05 12:43 PM
how do I rename a sheet jonwyn New Users to Excel 2 March 1st 05 08:36 PM


All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"