Thread
:
Rename active sheet
View Single Post
#
5
Posted to microsoft.public.excel.programming
Nigel[_2_]
external usenet poster
Posts: 735
Rename active sheet
Doesn't this assume that the last row in A and E are the same? The OP asked
for "last used cell with a value
in column A and E", which I read as - could be different?
See my solution that takes both value separately, however I should have used
the format function which would have been better!
--
Regards,
Nigel
"Rick Rothstein (MVP -
VB
)" wrote in
message ...
Here's something more compact:
Sub SheetRename()
Dim aPart As String, ePart As String, shtName As String
Range("A1").EntireColumn.Cells(Rows.Count, 1).Select
Selection.End(xlUp).Select
aPart = Selection
ePart = Selection.Offset(0, 4)
shtName = aPart & " " & Format(ePart, "m-d-yy h-mmAM/PM")
ActiveSheet.Name = shtName
End Sub
If compact is your goal, what about this for the body of your SheetRename
subroutine?
Dim R As Range
Set R = ActiveSheet.Cells(Rows.Count, 1).End(xlUp)
R.Parent.Name = R.Value & Format(R.Offset(0, 4).Value, " m-d-yy
h-mmAM/PM")
By the way, I used R.Parent.Name to keep the last statement from
word-wrapping in newsreaders... it should be replaced by ActiveSheet.Name
for clarity.
Rick
Reply With Quote
Nigel[_2_]
View Public Profile
Find all posts by Nigel[_2_]