Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default search for variable worksheet name and rename

I am importing several text files into a workbook. Each file name becomes the
name of its worksheet. There is one file name, however, that is too long for
the worksheet and its sheet name reverts to the default Sheet4 (or whatever
number sheet it happens to be at). The number of files that get pulled in
will vary. I am linking Access tables to each sheet and I need to be able to
have that sheet's name be constant. There may also be more than one of each
type of file. Example:

Joe Joe1 Joe2 Robert Robert1 Sheet6 Sheet7

I would need Sheet6 and Sheet7 to read Darcy Darcy1

I have tried many of the suggestions offered in here and have even tried
combining several. I can get it to loop through all the sheets, but it
renames every sheet, not just the ones names Sheet*. I have even tried
searching a specific cell in each sheet, but to no avail.

If it makes a difference, I am using Office Excel 2003.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default search for variable worksheet name and rename

Sub rnsheet()
For Each s In Sheets
If Left(s.Name, 5) = "Sheet" Then
s.Name = "larrydave" & i
i = i + 1
End If
Next
End Sub
--
Gary''s Student - gsnu200779
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default search for variable worksheet name and rename

You are beautiful!
I hadn't thought about checking the left side of the string.
Thank you so much!

"Gary''s Student" wrote:

Sub rnsheet()
For Each s In Sheets
If Left(s.Name, 5) = "Sheet" Then
s.Name = "larrydave" & i
i = i + 1
End If
Next
End Sub
--
Gary''s Student - gsnu200779

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default search for variable worksheet name and rename

You are very welcome.
--
Gary''s Student - gsnu200779
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
Rename files with variable names Robert_L_Ross Excel Programming 1 June 20th 06 06:52 PM
Using information from one worksheet, to rename inserted worksheet Lyn Excel Worksheet Functions 0 March 24th 06 12:54 AM
Rename the worksheet praveen_khm Excel Discussion (Misc queries) 1 January 17th 06 08:05 PM
Create a search Field within a worksheet to search command buttons Ed P[_2_] Excel Programming 1 December 14th 04 08:04 PM
VBA: rename a variable qwerqtzui Excel Programming 3 November 5th 03 05:03 PM


All times are GMT +1. The time now is 06:20 AM.

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"