Sheet name change

Torrez74

New Member
Joined
Jul 30, 2010
Messages
28
Hello all I need a bit of help with a workbook I'm working on please.

In the string;

Sheets("7-29").Select
Sheets("7-29").Name = "8-26"
Sheets("7-30").Select
Sheets("7-30").Name = "8-27"
Sheets("7-31").Select
Sheets("7-31").Name = "8-28"
Sheets("8-1").Select
Sheets("8-1").Name = "8-29"

I am changing the sheet names and they all are for ascending calender days. I would like to add a textbox before the string (i have the code for that) where you are asked "What is the first day of the period?". Where I need help is How do I make that answer the name of the first sheet and then change each sheet after to be in the same sequence?

Thanks for your help.
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Hi and welcome to the board!!
Maybe something like this??
Code:
Sub RenameSheets()
x = InputBox("What is the 1st day?")
For i = 1 To Sheets.Count
Sheets(i).Name = "8-" & x
x = x + 1
Next i
End Sub
lenze
 

Torrez74

New Member
Joined
Jul 30, 2010
Messages
28
I like it, i was thinking of directing them to input the day in the format MM/DD that way the whole string can be the name?? any thoughts?
 

Torrez74

New Member
Joined
Jul 30, 2010
Messages
28
OK so Ive been playing with this code, When it hit me that in the book I'm working on the first three sheets are constant but have all the dates for the Period in a row. Should I just write a Macro to rename the sheets according to the dates in that column? And can anyone point me to an example of that??
 

Torrez74

New Member
Joined
Jul 30, 2010
Messages
28
I just wanted to show how I got it done. I used the code;

Sheets(37).Select
sDay = Format(Range("A1").Value, "mm-dd")
ActiveSheet.Name = sDay

Sheets(36).Select
sDay = Format(Range("A1").Value, "mm-dd")
ActiveSheet.Name = sDay

Sheets(35).Select
sDay = Format(Range("A1").Value, "mm-dd")
ActiveSheet.Name = sDay

I have "A1" automaticly update and I go backwords so there should never be 2 sheet with the same name (it'll jam up)
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
You could shorten that:

Code:
For i = 37 To 35 Step -1
    With Sheets(i)
        .Name = Format(.Range("A1").Value, "mm-dd")
    End With
Next i
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,705
Messages
5,512,952
Members
408,927
Latest member
Elong0491

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top