![]() |
|
|
|
#1
|
||||
|
||||
|
Hi Paul,
I'll leave it to the OP to validate his/her assumption that the target sheet will always be the first sheet. I realised I forgot to post some sample Codename code for the OP, which is the approach I favour. Code:
Sub demo()
Const strNEW_NAME As String = "File 1"
'a workbook cannot have sheets with duplicate names
If Not SheetExists(ThisWorkbook, strNEW_NAME) Then
'sheet1 is the codename of the sheet, determined at design time
Sheet1.Name = strNEW_NAME
End If
End Sub
'a generic function to check if a sheet exists
Private Function SheetExists(ByVal wkbTarget As Workbook, ByRef strName As String)
On Error Resume Next
SheetExists = Not wkbTarget.Sheets(strName) Is Nothing
End Function
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to Rename a Quick Part | sleake | Word | 14 | 10-14-2013 09:21 AM |
Run-time error '91': Object variable or With block variable not set
|
tinfanide | Excel Programming | 2 | 06-10-2012 10:17 AM |
| Rename Files | gsrikanth | Excel Programming | 3 | 05-14-2012 03:03 AM |
"Auto-populating" data-worksheet to worksheet.
|
meggenm | Excel | 4 | 02-04-2012 02:04 AM |
Rename File
|
cksm4 | Word VBA | 2 | 02-25-2011 09:29 AM |