View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_5_] Jim Thomlinson[_5_] is offline
external usenet poster
 
Posts: 486
Default Naming worksheets

Sure. You should check to make sure that the name in the Cell will not be a
duplicate of another sheet name.

sheet2.copy After:=Sheet2
'The copied sheet is now the active sheet
With activesheet
if sheetexists(.range("A1").Text) = false then .name = .range("A1").Text
end with



Public Function SheetExists(SName As String, _
Optional ByVal Wb As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If Wb Is Nothing Then Set Wb = ThisWorkbook
SheetExists = CBool(Len(Wb.Sheets(SName).Name))
End Function
--
HTH...

Jim Thomlinson


"simonhall" wrote:


Hi,

I have a macro that makes a copy of sheet2 at the end of the workbook.

Is it possible to change the name of the new workseet to the contents
of a cell in sheet1?

Thanks, Simon


--
simonhall
------------------------------------------------------------------------
simonhall's Profile: http://www.excelforum.com/member.php...o&userid=30582
View this thread: http://www.excelforum.com/showthread...hreadid=502292