![]() |
#2
|
||||
|
||||
![]()
Hi,
Here's one way: Code:
Sub Main() Dim wstNew As Worksheet If WorksheetExists(WhichWorkbook:=ThisWorkbook, WorksheetName:="My New Worksheet") Then ThisWorkbook.Activate ThisWorkbook.Worksheets("My New Worksheet").Select Else With ThisWorkbook.Worksheets Set wstNew = .Add(After:=.Item(.Count)) wstNew.Name = "My New Worksheet" End With End If End Sub Function WorksheetExists(ByVal WhichWorkbook As Workbook, ByRef WorksheetName As String) As Boolean On Error Resume Next WorksheetExists = Not WhichWorkbook.Worksheets(WorksheetName) Is Nothing End Function |
Tags |
conditional, worksheet |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Create/delete New worksheet | ibrahimaa | Excel Programming | 5 | 01-16-2012 11:53 PM |
How to create a system folder with VB macro? | Joe Patrick | Word VBA | 4 | 12-17-2011 02:04 PM |
Create Custom menu using a macro | twnty2 | PowerPoint | 0 | 06-29-2011 04:26 PM |
How to create macro to paste text after style? | Srivas | Word | 0 | 03-16-2010 05:28 AM |
macro for comparing data from 3 columns and pasting into another worksheet | ashukla | Excel | 1 | 06-24-2009 05:01 PM |