Rename Sheets - But Not Every Sheet
May 2, 2008
I have 20 sheets in the workbook. 10 sheets are named YR1, YR2, etc. Once the user enters information on sheet "Assumptions" - names are setup and linked onto each YR page. So user enters CY10, which links to cell C5 on YR1 to show CY10.
I would like a macro that renames just the YR1, YR2, ....sheets, to CY10, CY11, .... I do not want any of the other sheets to change names.
(FYi - Using Excel 2003)
View 9 Replies
ADVERTISEMENT
May 9, 2012
How do I selectively rename sheets by sheet code name?
Instead of sheet1.name = "New Name" I need sheet1 to be a variable of a specific sheet.
View 4 Replies
View Related
Jul 31, 2013
I receive a workbook each day with approx 500 tabs of call data and I would like to relabel all the tabs with the user names. The user names are in a merged range "A7:M7". I'm having difficulty getting the following script to rename the sheets. Currently the values in "A7:M7" look like "User: ADAM ENGEMANN-558".
I am trying to delete each occurrence of "User: " while naming the sheets as well as removing the merged range before doing so that the names are in A7 only. The sheet names should look like "ADAM ENGEMANN-558", or, ideally just "ADAM ENGEMANN". For some reason my code will not modify the cells. (See attached example)
This works if I manually unmerge the cells before running and remove the ":".
VB:
Sub RenameSheets2()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Range("A7").Value <> "" Then
[Code] .....
This his how I modified it but it doesn't work on the supplied sheets. Please note that if I manually insert some blank sheets into my workbook and merge the cells etc it does work. There seems to be something odd going on with the sheets they are giving me. (they aren't protected)
VB:
Sub RenameSheets2()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Range("A7").Value <> "" Then
I tried adding the following to remove the merged ranges and remove 'User: ' from the names
Range("A7:M7").Select
With Selection
.WrapText = False
.MergeCells = False
[Code] ......
CallSample2.xls
View 3 Replies
View Related
Jul 24, 2012
I have a worksheet titled "master plan" with many columns of data. I want to create many tabs based on this data.
One tab I want that just has the data from columns C, F, A, E, G and L (in that order) Starting with the header data in row 2. And titled "LOB".
Then I want a different tab for each unique item in Row C with these same columns (C, F, A, E, G and L from "master plan" tab or A, B, C, D, E and F from new "LOB" tab). The tab name should be the unique row C value.
So for example, say that there about 20 rows where 'A' is in column C, about 30 with 'B' in column 'C' etc .... There should be a tab with the name 'A' with those 20 rows of data and a tab with the name 'B' with the 30 rows with B and so on.
I also would prefer not to have to delete the existing 'A' and 'B' tabs every time before recording the macro so if it can either create a new tab or replace an existing tab with that name if it already exists.
To make things a little more difficult.. for the (in this example) 20 items with an 'A' in column C, there are (at this time) 3 different possible items in column B of 'master plan'. I'd like to create 3 separate tabs for each unique value in column B and I want the name to be dependent on the data in Column B (for example, the three unique items in column B with a column C of 'A' are Red, Green and yellow. I want three new tabs set up for each and the tab names to be: if B = Red, then tab name = 'Stop', If B = Green, then tab name = 'Go', if B = Yellow, then tab name = 'Slow'.
I have something that partially works, but I have to create the 'LOB' tab first and it doesn't work if any of the sheets already exist. And it doesn't do the Red, Green, Yellow part.
Here is what I currently have:
Sub DeptTabs2()
Dim strSrcSheet As String
Dim rngSrcStart As Range
Dim rngSrcEnd As Range
Dim rngCell As Range
Dim strLastDept As String
Dim intDestRow As Integer
On Error GoTo ErrHnd
[Code] ..
View 6 Replies
View Related
Apr 8, 2009
how I can change this code to apply to only the sheets that are selected (grouped) as opposed to every sheet in the workbook?
For Each shName In ActiveWorkbook.Sheets
View 9 Replies
View Related
Sep 4, 2006
in the WorkSheet_Activate for Sheet 3, which changes the sheet name to the ComboBox Value. Is it possible to use the default name of the Sheet, in this case Sheet 3, if the ComboBox Value = "0". I have the following codes for a ComboBox & Userform:
Private Sub ComboBox1_Change()
Sheet3. Range("E1").Value = ComboBox1.Value
End Sub
&
Private Sub Userform Initialize()
ComboBox1.AddItem 0
For x = 1 To 60 Step 1
ComboBox1.AddItem Format(x, "0")
Next x
ComboBox1.Value = Sheet3.Range("E1").Value
I also have this code ..............
View 2 Replies
View Related
Oct 13, 2006
is there a quick and easy way to rename the Sheets In VBA Editor (they are currently all mixed up), i.e. I have Sheet221 followed by Sheet11 etc. Is there a way to reorganise them so that I get Sheet01 followed by Sheet02 etc.
View 5 Replies
View Related
Apr 22, 2007
i am looking for a macro that renames existing worksheets from multiple lists and have the new name appear in cell b1 of each new sheet.
List one: Worksheet name "Stats", cells b7:b20
Worksheets i would like renamed: Sheet9:Sheet22
List two: Worksheet name "Stats", cells 26:b34
Worksheets i would like renamed: Sheet48:Sheet56
View 7 Replies
View Related
Dec 29, 2007
I have a workbook containing many worksheets. The worksheets are clients in my system.
I have no big problems with my VBA code, but what I really thought was simple is causing my system to take very long time processing.
Sheets("Kunde mal").Select
Sheets("Kunde mal").Copy Before:=Sheets(3)
Sheets("Kunde mal (2)").Select
navn = Range("kundeNavn").value
ID = Range("kliNr").value
Sheets("Kunde mal (2)").name = navn & " - " & ID
Sheets("Kunde mal").Select
Why is this taking so many seconds?
Are there other ways to copy sheets?
View 6 Replies
View Related
Jun 18, 2008
I have a WorkBook with many Sheets "imagine Sheets.count=50"
9 of the CodeNames for this Workbook's sheets are: sht01. sht02, sht03, sht04, sht05, sht06...
If I want to change the name "not the CodeName" of say "sht01" I can use:
sht01.name="New Name"
but is there a way of doing this whitin a For Next this way:
For X = 1 To 9
Sheets("sht" & X.CodeName) = X ' the Name X is just for this eg
Next X
View 9 Replies
View Related
Jan 13, 2008
how to rename the sheets according to the current time 1201pm, 1202pm etc. i need a macro.
View 9 Replies
View Related
Aug 21, 2008
I have a macro which creates 4 worksheets. Unfortunately sometimes they are named by default "Sheet5", "Sheet6", "Sheet7", and "Sheet8" when the macro is set to "Sheet1", "Sheet2", "Sheet3", "Sheet4". My question, is there a way to rename the sheets directly after creating them so that the sheet in the very first position in the spreadsheet is named "Sheet1" (the same would go for sheets 2-4). The code below wont work if the sheet decides to be a name other then "Sheet5" so how do I point to the the worksheet known as Sheet5 without using its name and tell excel I want its default to be "Sheet1"?
Code below:
Sheets("Sheet5").Select
Sheets("Sheet5").Name = "Sheet1"
Sheets("Sheet6").Select
Sheets("Sheet6").Name = "Sheet2"
Sheets("Sheet7").Select
Sheets("Sheet7").Name = "Sheet3"
Sheets("Sheet8").Select
Sheets("Sheet8").Name = "Sheet4"
View 9 Replies
View Related
Oct 31, 2006
I'm tring to create a newsheet and rename the codename but it doesnt seem to be working. Here is my
Private Sub Update_Button_Click()
AddYear = YearBox.Value
WFName = "WF Tracker SITE " + AddYear
wf = "WF_Edin_" + AddYear
Sheets.Add After:=WF_Template
ActiveSheet. Name = WFName
Sheets(WFName).CodeName = wf 'This line wont work
End Sub
View 9 Replies
View Related
Feb 2, 2010
I am getting the error from the title of the thread when I try to change a worksheet name.
This worksheet name doesn't already exist in the workbook and I don't have any other files currently open.
I'm not entirely sure what is causing this, but I do need the sheet to be the name I am trying to change to.
View 9 Replies
View Related
Jan 30, 2014
In column C I got some data like this:
Number of .csv
01
02
03
04
Number of .csv
05
06
07
08
Notice that there is an empty cell in between.The data starts at C12 up to C21. The data is in Sheet2.There are also 8 more sheets( Sheet3 to Sheet10). I want to rename each sheet, starting from Sheet3 according to each cell. For example the Sheet3 to be renamed to 01, Sheet4 to 02.
What I can do is something like this:
[Code] .....
And repeat this code for every block of data I got by changing everytime the i and the a. But this method is not so optimized because there are cases that the number of rows for each block is not the same and I have to change everytime the i counter. Is there any way to do 1 loop for all the sheets using maybe Worksheets.Count and another dynamic loop for the rows ? The data always start every 6 rows eg( C12, C18 etc). Also I was thinking to define an integer representing the number of rows for the loop...
View 6 Replies
View Related
Aug 24, 2006
Say you have a userform with 10 TextBoxes, let’s call them TxtN1…TxtN10 and your workbook has 10 sheets, say “Sheet1”…”Sheet10”. Now if one wants to code a procedure to rename those worksheets when the user hits a command button it’s simple enough.
Sub Rename_click()
For i = 1 To 10
With Sheets(“Sheet” & i )
. name = TxtN & i
End With
Next i
End Sub
But now if the user then changes the textboxes TxtN1…TxtN10 to a set of new strings it’s obvious that the following coding segment will not work:
For i = 1 To 10
With Sheets(TxtN & i)
.name = TxtN & i
End With
Next i
It goes without saying that the program will try to select the worksheets with the new name (and they obviously don’t exist yet)…
View 6 Replies
View Related
Jul 30, 2009
I'm trying to create a copy of the active sheet and then rename the new copied sheet to what's in cell O4, which is a formula (see below) and then paste value cell O4 in B3 of the copied sheet. However, when I run this macro it doesn't seem to like the second line where I am renaming the sheet (run time error '1004').
"O4" =DATE(YEAR($B$3),MONTH($B$3)+1,DAY($B$3))
Sub NewMonth()
ActiveSheet.Copy Before:=Sheets(Sheets.Count)
ActiveSheet.Name = Range("O4").Value
ActiveSheet.Range("O4").Copy
ActiveSheet.Range("B3").PasteSpecial Paste:=xlPasteValues
End Sub
View 9 Replies
View Related
Nov 10, 2009
I have 5 sheets. In the first sheet I have set up 4 cells where I want the contents of them to automatically rename the other 4 corresponing sheets.
Eg.
In Sheet 1, Cell B6, I want the contents (which will be text) to be the name of sheet 2 automatically.
In Sheet 1, Cell B7, I want the contents (which will be text) to be the name of sheet 3 automatically.
View 8 Replies
View Related
Oct 1, 2009
I am working with a workbook that has data automatically entered each time a new child is enrolled to the program. The child's data is automatically entered to the sheet named "Intake". What I need to do now is rename that sheet using the child's name as the sheet name, but also keep the sheet named "Intake" for the next entry. I would then like to sort the sheets alphabetically but leaving the "Intake" sheet either as the first sheet or the last sheet. I have attached an example of the workbook I am working with.
View 6 Replies
View Related
Aug 11, 2006
I have a list of names in sheet1, starting with cell A3. I would like to copy sheet3, insert it after sheet3 and rename the sheet to correspond to the names in the list.
If i have 30 names I would like 30 sheets. If i add a name, I would like to repeat the copy, insert and rename steps for the extra names as i add them.
View 7 Replies
View Related
Apr 13, 2008
Why do I get the error: "Runtime error 1004: Cannot rename a sheet to the same name as another sheet, a reference object library, or a workbook referenced by Visual Basic"?
And how do I fix it? I have a macros that someone else made (thank you) and I need to make the macros create anywhere from 5-125 sheets based on the information added in sheet 1. How can I do this whe it stops me after 5 or so with the error above.
View 10 Replies
View Related
Dec 21, 2011
I have about 100 products and each has its own sheet that I fill with data. Once I have finished with a sheet I rename it and create a copy and then hide the original and delete the entered data from before and start over.
Is there a way I can make it so when I hide a sheet it will automatically create a copy and delete a specific range?
View 1 Replies
View Related
Oct 27, 2008
EXAMPLE: Complete Sheet called "Day1". When day1 is complete you click on button and it then copies itself and creates and renames new sheet to "Day2", then when "Day2" is complete you click on button and it then copies itself and creates and renames new sheet to "Day3", and so on and so forth to "Day30".
View 9 Replies
View Related
Oct 11, 2013
What I'm looking to do is copy sheet named January, and paste into a new sheet naming it February, then in February copy and paste into another new sheet naming it March and so (but keeping previous months). My thinking was a pop up to name the sheet to copy then another to name the sheet that it's pasted in.
View 2 Replies
View Related
Aug 24, 2012
I run a report each month which renames the tab name called ex. "xxxxx Report 8". The 8 meaning for the month of August. I have created a macro to rename the tab, but each month when i generate the report the tab name change, hence i would have to change my macro again to reflect the tab name. What formula could i use in VBA to change the name of tab so i would not have to change my macro each month?
I currently use as shown below, which does not work since the number changes each month when i generate the report):
Sheets("xxxxx Report 8").Select
Sheets("xxxxx Report 8").Name = "Monthly Report"
View 4 Replies
View Related
Dec 22, 2006
I am receiving a the 'Rename Sheet' dialogue box when I double left click on a tab? Normally, it will allow editing in the name of the tab, not a pop up.
View 9 Replies
View Related
Jul 24, 2006
I first insert a new sheet and then i want something (inputbox or so) where i can give in the new name of that sheet (i have to do that a lot of times, so i wont do it manually) is there any solution for this thing??
View 2 Replies
View Related
May 5, 2014
I'm trying to copy the a name from cell X2...JohnDoe and rename the current sheet with the contents of X2. I'm using the following code and getting my sheet named as "True"
Sub SheetName()
'
' SheetName Macro
'
Dim ShName As String
ShName = Range("X2").Select
Selection.Copy
Sheets.Add.Name = ShName
End Sub
View 4 Replies
View Related
Jun 12, 2014
I have an electronic meter (Fluke AirCheck) that provides me with reports in the form of excel documents. I need to combine those documents and have a page/worksheet that contains a legend and some notes etc. for reporting to management.
Given:
I have a folder with nearly identical workbooks. All contain 4 worksheets:
Document map
Sheet2
Sheet3
Sheet4
Goal:
1. Copy and combine, either specific sheet(s) or all the sheets from multiple workbooks into a new workbook (with prompting)
2. Rename the worksheets as the workbook file names and existing worksheet names combined.
Example:
Workbook name is "101B.xls"
Worksheet 1 would be = "101B - Document Map"
Worksheet 2 would be = "101B - Sheet2"
Worksheet 3 would be= "101B - Sheet3"
Worksheet 4 would be= "101B - Sheet4"
Results thus far:
Okay so I managed to find a script that does most of what I need:
[Code] .....
For renaming the worksheets I have tinkered with:
[Code] .....
But alas none of that works. I can also only copy 1 sheet at a time currently.
Another issue which seems to have reared its ugly head in the copy and paste function as the text on my new worksheets is white on white when the originals are black text on white. I can select the new worksheet and select all cells and hit "Automatic" on text and it fixes it but that's a pain on 100+ worksheets. So I need some sort of copy /paste special command, I think to make that work too.
View 5 Replies
View Related
Dec 13, 2007
Is there a function to do this or only VB code?
View 14 Replies
View Related