Clever way to swap sheet names
Hi Bob. Do you know if there's a way that this swap function will
work without reordering the tab positions after the swap occurs??
I prefer that the tabs stay in place and only their names get
swapped.
thank you
"Bob Phillips" wrote in message
...
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
|