![]() |
|
#2
|
|||
|
|||
|
If you want to add a worksheet and then give it the name of the active cell the code below will do that.
Code:
Sub CreateNamedWorksheet()
Dim wb As Workbook, nws As Worksheet, NewName As String
Dim ws As Worksheet, cws As Worksheet
Set wb = ThisWorkbook
Set cws = wb.ActiveSheet
If ActiveCell.Value <> "" Then
NewName = ActiveCell.Value
For Each ws In wb.Worksheets
If ws.Name = NewName Then
MsgBox ("The name " & NewName & " is already in use. No new worksheet added.")
End
End If
Next ws
Set nws = wb.Worksheets.Add
nws.Name = NewName
Else
MsgBox "The active cell has no value to name the new worksheet"
End
End If
cws.Activate 'Use a ' right before this line to select the new worksheet.
End Sub
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Help Coloring a cell in Sheet one if data is missing from another sheet
|
Aeducan | Excel | 1 | 06-22-2014 04:49 PM |
How to set a hyperlink from a pp presentation into a CELL from an excel sheet
|
Sabi | PowerPoint | 1 | 04-30-2013 06:36 AM |
Insert Excel sheet
|
markg2 | Word | 1 | 12-15-2010 12:19 PM |
| copy cell from sheet 2 to sheet 3 macro | slipperyjim | Excel Programming | 1 | 02-18-2010 01:31 AM |