M
maperalia
I have this program that changes the sheet name automatically (see below).
However, I got the following problems:
1.- When one of the cell does not have information the program does not
continue just stop.
2.- If the cell D15, D16 and D17 have number. The program changes these
tag’s names. However, stops as soon find that the next cell is empty.
I need the program to just change the sheet names that have description in
the cells.
Could you please help me with this matter?
Thank in advance.
Maperalia
'****START PROGRAM***********
Option Explicit
Sub RenameSheets()
Dim myDateTime As String
myDateTime = Format(Worksheets("Information").Range("D15").Value,
"mm-dd-yyyy")
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D16").Value,
"mm-dd-yyyy")
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D17").Value,
"mm-dd-yyyy")
Sheets("Sheet3").Select
Sheets("Sheet3").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D18").Value,
"mm-dd-yyyy")
Sheets("Sheet4").Select
Sheets("Sheet4").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D19").Value,
"mm-dd-yyyy")
Sheets("Sheet5").Select
Sheets("Sheet5").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D20").Value,
"mm-dd-yyyy")
Sheets("Sheet6").Select
Sheets("Sheet6").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D21").Value,
"mm-dd-yyyy")
Sheets("Sheet7").Select
Sheets("Sheet7").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D22").Value,
"mm-dd-yyyy")
Sheets("Sheet8").Select
Sheets("Sheet8").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D23").Value,
"mm-dd-yyyy")
Sheets("Sheet9").Select
Sheets("Sheet9").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D24").Value,
"mm-dd-yyyy")
Sheets("Sheet10").Select
Sheets("Sheet10").Name = "" & myDateTime & ""
End Sub
'****END PROGRAM***********
However, I got the following problems:
1.- When one of the cell does not have information the program does not
continue just stop.
2.- If the cell D15, D16 and D17 have number. The program changes these
tag’s names. However, stops as soon find that the next cell is empty.
I need the program to just change the sheet names that have description in
the cells.
Could you please help me with this matter?
Thank in advance.
Maperalia
'****START PROGRAM***********
Option Explicit
Sub RenameSheets()
Dim myDateTime As String
myDateTime = Format(Worksheets("Information").Range("D15").Value,
"mm-dd-yyyy")
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D16").Value,
"mm-dd-yyyy")
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D17").Value,
"mm-dd-yyyy")
Sheets("Sheet3").Select
Sheets("Sheet3").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D18").Value,
"mm-dd-yyyy")
Sheets("Sheet4").Select
Sheets("Sheet4").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D19").Value,
"mm-dd-yyyy")
Sheets("Sheet5").Select
Sheets("Sheet5").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D20").Value,
"mm-dd-yyyy")
Sheets("Sheet6").Select
Sheets("Sheet6").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D21").Value,
"mm-dd-yyyy")
Sheets("Sheet7").Select
Sheets("Sheet7").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D22").Value,
"mm-dd-yyyy")
Sheets("Sheet8").Select
Sheets("Sheet8").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D23").Value,
"mm-dd-yyyy")
Sheets("Sheet9").Select
Sheets("Sheet9").Name = "" & myDateTime & ""
myDateTime = Format(Worksheets("Information").Range("D24").Value,
"mm-dd-yyyy")
Sheets("Sheet10").Select
Sheets("Sheet10").Name = "" & myDateTime & ""
End Sub
'****END PROGRAM***********