Not much you can do cleverly I would have thought, but here is one way
Public Sub Test()
Call SwapNames(Worksheets("Sheet2"), Worksheets("Sheet3"))
End Sub
Public Function SwapNames(sh1 As Worksheet, sh2 As Worksheet)
Dim tmp As String
tmp = sh1.Name
sh1.Name = sh2.Name & "_"
sh2.Name = tmp
sh1.Name = Left(sh1.Name, Len(sh1.Name) - 1)
End Function
---
HTH
Bob Phillips
"Robert Crandal" <(E-Mail Removed)> wrote in message
news:_C__m.2$(E-Mail Removed)...
> I'm looking for a clever or efficient or cool way to
> swap the names of 2 sheets using just one function
> or subroutine call.
>
> Suppose my workbook contains one sheet that
> is named "foo" and the other is named "foo2".
> I would want my function call to swap the names
> of both sheets. If the function is called again,
> it should reverse the process.
>
> Everybody here always seem to have better or
> shorter methods than mine, so I would greatly
> appreciate your ideas.
>
> thank you everyone.
>
>
|