Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Excel


Renaming Worksheets Via VBA

I am probably just having a stupid moment, however I have a problem

Whats the best way to rename a worksheet using VBA?

I was going to use a count function to count the number of worksheets, then change worksheet (eg) 10, 11 & 12

View Complete Thread with Replies

Sponsored Links:

Related Forum Messages:
Renaming Tabs On The WorkSheets
I mean renaming tabs on the sheets, the tabs at the moment are called Output 1 (*****) instead of Sheet 1 etc.. and i would like that changed to contents in cell A9. If possible only the Output 1 will be removed and it will change to something similar "X-Ray (5E4TT)"

i have a workbook with worksheets named Output 1 (*****)

(the stars being a five digit/letter code - the only thing that changes on the workbook)

now the problem is, i pull of reports and sometimes worksheets can be up to one hundred.. now in cell a9 is the name of the report. I have found vba code to rename sheets to cell contents **extract below**

but any chance of renaming contents of cell a9 to a worksheet named Output 1 (*****) etc.. and if the contents of cell a9 can be trimmed so only certain part of a lengthy title

Sub RenameTabs()

For i = 1 To Sheets.Count
If Worksheets(i).Range("A1").Value <> "" Then
Sheets(i).Name = Worksheets(i).Range("A1").Value
End If

End Sub

View Replies!   View Related
Adding And Renaming Worksheets Using VBE
I've undertaken a project for work with my very very limited knowledge of Excel VB.

What I am trying to do is automate the process of creating a new worksheet in a "Master" Workbook, rename and save that worksheet with the date it was created.

Each worksheet will hold a list of dates for staff members who have attended or attempted courses for that week and the information will come in via email in separate pre-created worksheet templates. The consolidated weekly data will ultimately end up in an MS Access db (but needs to be sorted and validated before upload).

Here is the code I have so far:

Private Sub AddSheets()

Application. ScreenUpdating = False

Worksheets.Add.Move Before:=Sheets(1)
Worksheets.Visible = True

Dim myDate
myDate = Date

Sheets. Name = Date

End Sub

Using VB6.3 in Excel 2000

View Replies!   View Related
Renaming Worksheets In Files In A Directory
Hope i can get some help here as my vba experience is extremely limited. I'm trying to run a macro from a spreadsheet that will go down a list of file names that i have entered in a worksheet where the macro resides and open those spreadsheets and rename the worksheets in each file according to a list of names that i have entered in the 10 columns next to the file name. It's easier to explain with the layout of my macro spreadsheet: ....

View Replies!   View Related
VBA - Renaming Tab
I have a macro that copys a worksheet into a new workbook - can anyone tell me the VBA to rename the new tab with a cell reference?

View Replies!   View Related
Renaming A Tab In A Workbook
I have several tabs in a workbook that need different names depending on what is selected from a drop down menu on one of the sheets - "Staff Details" sheet. Any clever persons out there able to help?

View Replies!   View Related
Renaming Tabs ...
Is there a way to rename tabs from a seperate list. Or link the Tab name to a list?

View Replies!   View Related
Renaming A Cell ...
I have renamed a cell to "final"

Now im trying this:

But that doesnt work, I want the cell just above final.

And I cant refer to the cell above directly due to some factors.

So how could say final - 1?

View Replies!   View Related
Auto Renaming A Tab
Im sure ive seen this somewhere before but i cant find it after searching.

I would like the tab to auto rename with whatever is input into cell A1.

View Replies!   View Related
Renaming Files ...
I have a folder containing pictures.

I have an excel sheet containing data.

The pictures' filenames are #s which are located in Column A of the spreadsheet. I would like to be able to have excel take the picture name, lookup which Row it is and then add the information from Column B, C, D and E into the filename. It would need to do it for all the pictures located in the folder.

View Replies!   View Related
Renaming Files Using VBA
I have forty files in a folder that are generated by a system every day.
The files all have something in common, they all include "V9TEST" in them.

for example:

I would like to run a script that would rename these files in the folder, taking out the V9test part.


View Replies!   View Related
Sequential Tab Renaming
Is it possible in Excel to automatically rename all the tabs of a workbook in one move in a sequential format - eg renamimg 52 weekly tabs Week 1, Week 2, Week 3 etc.

View Replies!   View Related
Renaming Sheets
Is there a way you could have a sheet named after the date like the formula of NOW

View Replies!   View Related
Renaming Tabs Macro
is there any way that i can adjust this code so that if there are not enough worksheets in my workbook to support my list that more worksheets will be made and renamed? Specifically I would like to copy the first worksheet and then rename it based on my list. also... If I have more worksheets than my list requires it can delete unused worksheets?

Sub NameSheets()
Dim i As Long
Dim ws As Worksheet
i = 1
For Each ws In ActiveWorkbook.Worksheets
If ws.Name "Sheet Names" Then ws.Name = Sheets("Sheet Names").Cells(i, 1)
i = i + 1
Next ws
End Sub

I have a list on "Sheet Names" that changes the tab names on each sheet when i run the macro

View Replies!   View Related
Renaming Objects In TXT File
I manually Copied and Pasted contains in TXT File.
The TXT file is as below.
It has only 1 Column


What I want is to run some VB Script so that anything after / is ignored
and the Output shold be reformatted as below

The Above O/p is anything aftyer / is ignore and the last character of the 1st field is A is replace with 0 and B is replace with 1.

View Replies!   View Related
Renaming Tabs With Dates
I´d like to have a single workbook for each calendar year, with a tab for each date Monday through Friday (like 11-Jun, 12-Jun, etc.). I could then type the patients` names and times of arrival, among the other information I track. Alternatively, I could have a workbook for each month of each year (titled for example 2007 June or 2008 August), with the tabs titled by the date of the month (like 1, 4, 10, etc).

Is there an easy way to do this without manually renaming each tab for each day of the year?

If it´s too hard to limit the macro to create tabs for only the days of the workweek, it wouldn´t bother me if the workbook had to include every day of the week (Sunday-Saturday). I can always go back and delete the unnecessary ones.

View Replies!   View Related
VBA: Inserting And Renaming A Worksheet
I'm relatively new to VBA and require programming help with the following:

I have created a button to add a specific worksheet template ("TE - Template") after another worksheet ("CO - Cockpit") and then name it:

Sub Add_worksheet()
Sheets("TE - Template").Select
Sheets("TE - Template").Copy After:=Sheets("CO - Cockpit")
ActiveSheet.Name = "AL - Class 1"
End Sub

However, I would like to let Excel check (via VBA) if the "AL - Class 1" worksheet already exists. If it does, the same template sheet should be added but named differently: "AL - Class 2". This should be possible for X worksheets (i.e., "AL - Class (X + 1)" everytime I add a new template worksheet. Thus, I would like to keep the same name (i.e., "AL - Class"), but with an increasing number (i.e., 1, 2, 3, X).

how I should amend the above code or supply me with a better (and efficient) way of programming this query?

View Replies!   View Related
Renaming Files In A Folder
Every week I get a folder full of files and I have to rename them with a week ending date...Below is what I hacked together, but it's not working...

Sub Rename()

Dim OldName, NewName, npath As String
weekendingdate = InputBox("What is W/E Date??")
npath = "J:Test*.pdf"
While Smith ""
OldName = Smith: NewName = Smith & weekendingdate
Name OldName As NewName

End Sub

View Replies!   View Related
Renaming Files From A Spreadsheet
to take a spreadsheet in excel and rename files with it. I will get all the columns together and

named properly by using the concatenate function. So when i go to rename i would have a

list of say 5,000 things to rename. In column A will be the full path. In column B will be the

new name i want it to replace the old one with extension and all. The reason i want to do this

is because that way i can work with the 5,000 files column A, B, C, D, get everything the

way i want it and then concatenate them. Then rename the files after copying and repasting

them so there is no formula. This would just be much easier than having to go to each

individual file and rename. also a lot easier to be able to compare and see what is going on

in spreadsheet i can sort compare. just a lot easier. i have messed around with excel some

but not macros much. what i would like to do is for a macro to look in A1 for path then

rename with B1. then A2 for path then rename with B2. loop through all rows until there is

nothing in A? that way there does not have to be a certain number of files. i do not know if

C: estSGB04SGB04-08 - Frank Sinatra - Wives And

rename to B1

SGB04-08 - Sinatra, Frank - Wives And

running excel 2000 windows xp

View Replies!   View Related
Replicating Sheet And Renaming
I got a workbook containing a worksheet called APheb1.

I would like to create a macro that would replicate this worksheet and rename it APheb2, APheb3 etc... till a number i specify. For example if i specify 90, then it would replicate APheb1 90 times till APheb90.

I have recorded a macro that replicates the file but i cannot find a solution for the renaming part.

View Replies!   View Related
Renaming Charts In 2007
In the old Excel it is possible to rename a chart by pressing SHIFT+Mouse Click and then write a new name in the upper left corner name box. You can apparently do the same thing in Excel 2007, but the new name doesn't stick.

View Replies!   View Related
Inserting + Renaming Tabs Via A Macro
Just a quick on i hope. Im trying to create a macro that adds a worksheet/tab and Rename it to the month after the tab already showing.


if i already have two tabs one dated january and the other named february i require the macro to say march then the next run would be april if you get my drift.

View Replies!   View Related
VBA Shortcut For Renaming Multiple TextBoxes
Is there a shortcut to rename multiple TextBoxes?

So far I've been renaming each individual TextBox manually. This takes forever...

I have a lot of TextBoxes & hope there is a faster/easier solution.

TextBox1 --> OtherName1
TextBox2 --> OtherName2
TextBox3 --> OtherName3
TextBox4 --> OtherName4
TextBox5 --> OtherName5
TextBox6 --> OtherName6
TextBox7 --> OtherName7
TextBox8 --> OtherName8
TextBox9 --> OtherName9
TextBox10 --> OtherName10

View Replies!   View Related
Renaming Multiple Tabs By Month
I would like to rename multiple tabs (12 in all) on a spreadsheet by month only. I highlighted all tabs and then performed a cut and past from the previous year spreadsheet, but when the paste was complete the tab names were missing. I need January through December on the 12 tabs. Does anyone know of a shorter process than renaming each tab individually? I have called several people and asked the same question and they are curious if there is a way to do this also and asked that I let all of the know what I find out, so you would be helping quite a few people in several different companies (If that gives you happy thought, then good for all of us ).

View Replies!   View Related
Renaming Worksheet Tabs Macro
I would like to create a macro that would bring up an input box or preferably a list box that will allow me to input information for a sheet/tab name where where "TBL NPL NGRPL" appears in the code at the end of this message. The macro needs to be available to any new file created

The only worksheet names needed are below.


This is the extent of my ability:

Sub Macro1()
Sheets("Sheet1").Name = "TBL NPL NGRPL"
End Sub

I created six macros, but there must be an easier way.

View Replies!   View Related
Copying Worksheet To Same Workbook And Renaming It
i would like to use a macro which copies a worksheet from a workbook to the same workbook and paste it at the end and then renaming it... everything using a macro...

View Replies!   View Related
Event Triggered When Renaming Sheet
I need to declare an event that happens when a worksheet is renamed

the code that would trigger the event is

View Replies!   View Related
Parsing/renaming Data In A Cell

ABCDE1Source DataDesired Result
Include these extensions: Exclude these extensions:2OLD.FILENAME.rar.htmNEW.FILENAME.rar


I'm looking for a formula which can take my original data (column A) and "transform" it into what you see in column B.

I am transferring large amounts of files from various servers to my ftp and back out again. My original data are url filenames which of course, are named differently and not how you see it in my example.

The filenames themselves are preceeded by website names and varoius folder/path names. I edit the links to include various Usernames and Passwords and at the same time, rename the original filenames. Then I transfer the files to my ftp.

Most of the files have a ".part*.rar" extension at the end, so my formula has only included this scenario. Rather than manually editing my formula everytime a different extension is present (about 20-30% of the time), I would like to find a way to automatically look at a table/list of possible extensions (D2:D7) which are to be recognized for the sake of finding the end of the filename itself, so that I can rename (SUBSTITUTE) the original filename to that of my choice (cell D13) and of course, also include the original extension(s) of the source data (keeping this is important, especially in the cases where ".part*.rar's" are present). The list of extensions in cells E2:E7 are to be excluded from the new filename.

My present formula works fine for the editing of the username and passwords for various servers and for finding the beginning of the filename in the original url. It also works fine for finding the end of the filename (for the sake of renaming it), but only in cases where a .part*.rar" is present.

View Replies!   View Related
Move/copy And Renaming Sheet
I have the following code to move/copy worksheet and then copy and paste
special values. Is it possible during this process to get the user to change the 'moved' worksheet name ?

View Replies!   View Related
Renaming Of Worksheet Tabs From List
I have a workbook with 37 sheets in it. 36 of them are three per month (e.g JanCash, JanWeekly, JanMCR, etc) Since we make updates/ changes to the file throughout the year I cannot reuse the files. Also since we have accounts on different fiscal years, I need a way to rename the sheet tabs from a list. Does anyone know how I can do this with VBA code?

View Replies!   View Related
Activechart.export Not Renaming Temp File
I am trying to export a chart using the code below, the loops change the data that is used to produce the chart:

Dim strFilename As String
Dim strExt As String
Dim lngProfile As Long
Dim lngOption As Long
For lngOption = 1 To 3
Range("nmOption") = Choose(lngOption, "Existing", "Option 4", "Option 5")
For lngProfile = 1 To 4
Range("nmProfile") = "Profile " & lngProfile
ActiveSheet.ChartObjects("Chart 13").Activate
strExt = "gif"
strFilename = ThisWorkbook.Path & "Images" & _
Range("nmOption") & "_" & Range("nmProfile") & "." & strExt
ActiveChart.Export strFilename, strExt
Next lngProfile
Next lngOption

Each export command creates a file with the correct name but no data (0kb in size) and a temporary file that is the correct file type (I have tried both jpg and gif).

I could try and copy the temporary file, but why does Excel not finish the job? I have tried to put a loop in and also added DoEvents after the export but no joy.

View Replies!   View Related
Renaming Sheets (newly Opened Workbook And Change It's Name)
I'm experimenting a bit with this code. The idea is the following:

I've got one spreadsheet (ThisWorkbook) were I define 5 names for 5 worksheets in all files of a specific folder (c: emp). I get stuck at this line: "wb.Sheet2.Name = myval2", since I'm for some reason not able to activate the newly opened workbook and change it's name....

Sub wd_testing()

Dim I As Long
Dim wb As Workbook
Dim firstrow As Long
Dim sht As Worksheet
Dim cell As Object
Dim count As Integer
Dim myval2 As Variant
Dim myval3 As Variant
Dim myval4 As Variant
Dim myval5 As Variant
Dim myval6 As Variant
Application.ScreenUpdating = False

It's important to mention that there is no name conflict and the names work when entered manually.

View Replies!   View Related
Renaming Workheet As Date Format (cell Reference) Using VBA
I download & import CSV files/ sheets from bank, visa accts etc & I am trying to automate the processes I use including ensuring I (& others) will use the same naming conventions eg visa "yymm" = V0701, Direct Cedits = DC0701 etc. I am having trouble renaming or ensuring the active sheet is named according to the date in A3 eg in the example I want the sheet to be renamed V0702 as the date in the cell is 02/02/07 "dd/mm/yy" format ( imperial system). In BOLD is what I have & the renaming is messy becuase I searched the forum, Walkenbach's bible & help menu.

Sub VisaMonthlyAcct()
Dim shtName As String
Dim newName As String
'ActiveSheet.Name = shtName
newName = "V" & Format(DateValue("A3"), "yymm")
'Old name for future reference = Visa0701 (2)
ActiveSheet.Name = newName
Worksheets(shtName).Name = "V" & Format(Range("A3"), yymm)
'Worksheets("Visa0701 (2)").Name = "V" & (FormatDateTime(Range("A3"), yymm))
'To select Date column & format
Range("A3:A66").Selection.NumberFormat = "dd".............

View Replies!   View Related
Renaming Sheets: Replace The Word "March" In The Title
What I am attempting to do is to replace the word "March" in the title of worksheets with the word "April" while preserving other characters in the name, i.e. for the sheet named "Marchweek4", have it renamed to "Aprilweek4". The code that I have so far will not replace only the "march" string but will replace the entire name which is not quite what I want.

View Replies!   View Related
Renaming Excel File With "save As" Macro
I have a short excel sheet where different departments have to input some data.

I am kind of new in VBA programming, so I mainly copy pieces of written macros and paste them together.

I have a "save as" macro so that we have a standard/sequential file name: ....

View Replies!   View Related
Update A Cell Value From A Previous Sheet After Copying The Sheet And Renaming It
I have copied a sheet, moved it to the end and renamed it with a date that is in cell "A1"

Now after that process is finished I need it to update the date in cell "A1" of the newly created sheet with the next day's date.

I am stuck however referring to the previous sheet to update the date value in "A1"

View Replies!   View Related
Loop Through Worksheets Not Working (delete Some Hyperlinks In Column A On 50+ Worksheets)
Just need to delete some hyperlinks in column A on 50+ worksheets. Thought a loop through all the worksheets would do it. Only works on active sheet. Forgive my ignorance, don't really even know where it goes, once it works - module or workbook?

View Replies!   View Related
Renaming Worksheet Names From Data In Worksheet
I use a web query to import into an excel workbook. As data is changed on the web that the query runs against, I would like the name of the sheet that is being imported into to change to one of the cells that is being imported.

View Replies!   View Related
Loop Across Worksheets: Perform The Same Process To All The Worksheets In My Workbook
I'm trying to perform the same process to all the worksheets in my workbook. This is the code I have now, but it will only apply to the single active worksheet:

View Replies!   View Related
Selecting Worksheets Array When #of Worksheets Will Vary
How do I modify this macro so that the worksheet array will select all the worksheets except sheet 1?? My workbooks will have varying numbers of worksheets ...

View Replies!   View Related
Clearing Data In All Worksheets Except Last 2 Worksheets
I need to write VBA code to clear all Values, all values beginning with an = sign for eg = 9725, except formulas and text on all my worksheets, except the last 2 worksheets.

View Replies!   View Related
Renaming Cell Name With Cell Value
Is it possible to rename the Name Box for a cell with the value of the cell. For example: the value of A1 is 2, how do you change A1 to 2.

View Replies!   View Related
Renaming A Named List Or Adding To A Named List
So I created a list


and named it "Alphabet"
but now I have E and F and would like to make the list


and name it "Alphabet" again

however, when I select it all and make it Alphabet, it selects A to D automatically

is there any way I could make A - F named Alphabet?

View Replies!   View Related
File Names :: File Renaming Each With The Names I Have On Another List
I have a task I would like some assistance with…

I have a work book that I have to copy over 70 times for over 70 work locations. As you can see, this will require different file names for each location.

I would like some have help with a code that I can use. If possialbe I like a code that will make copies of the file renaming each with the names I have on another list. Is this feasible?

View Replies!   View Related
Add Row In 2 Worksheets
I need to add a row in tab "Clients", every time I have a new customer. Then I need to add that same row in another tab "Master". I tried using a macro but it copies the same row with the same information again and again.

Basically i need to add a row, put in some info and that automatically the same row is added in another tab.

View Replies!   View Related
If...Sum Across Worksheets
I have a worksheet titled Current, which houses data about current Work Orders out of our shop.

In column E I have the departments listed
In column I, I have the numbers of hours worked on a particular job.

In another worksheet I am trying to sum the total hours of work performed for a particular department.


Here is the formula I tried to create, but it returns FALSE?

View Replies!   View Related
Getting The Max Value From Two Worksheets
how to get the maximum value from two worksheets and displays the output or maximum value on another sheet? I have attached a sample worksheet. Sheet 1 and Sheet 2 contains values to be compared while sheet 3 should contains the output or maxed value.

View Replies!   View Related
VBA UDF To Add Worksheets
I want a UDF to copy a data range, add a new worksheet and paste the range into it as part of a function calculation not a user interface macro.

I simply cannot add a worksheet from a Sub that is called by a Function, only by a Sub launched as a macro. As shown below - the Function quits at Sheets(SheetName).Select as there is no such Sheet.

It seems that VBA cannot add worksheets from UDFs. Does VB .Net do this? How can I add sheets within a UDF without user interface objects?

View Replies!   View Related
Sum Between Worksheets
I have a large data file, to make work easy for myself i have seperated each section into different worksheet. well my problem is. i want to use this very simple method for SUM "=SUM(A1+A2+A3)". If I am doing this on a same worksheet its no problem at all.

Is there any way to use this same simple method between different sheets?
like. Sum of A1 of sheet1 + A1 of sheet2 + A1 sheet3 here.. A1 is a cell and sheet 1 onwards are different sheets

View Replies!   View Related
Merge Worksheets
I need to merge for worksheets (in the same workbook) into 1 large worksheet.

Is there a command that does this? Or do you guys have a custom macro that does this?

View Replies!   View Related
Stale Worksheets, Why?
I'd like to update some of the hardcoded numbers to functions that would pull from lookup tables. However, when I enter this in A1,

="Blah, blah "&B1&"."

In a "fresh" spreadsheet I get "Blah, blah 2009." , in cell A1 where B1 has 2009 typed in.
In a "stale" spreadsheet I get "#VALUE!" in cell A1 (with 2009 typed in B1).

I've tried right clicking--> format cells and then changing to a variety of formats w/no luck at all. The only thing that works is to create a new sheet in the workbook and reformat the table and cells by hand. Clearly this is an ineffective workaround.

So, exactly what is the property that I need to reset in the "stale" worksheets that will allow, ="Blah, blah "&B1&"." to be read properly?

View Replies!   View Related
Copyright © 2005-08, All rights reserved