workbook
Sub demo()
Dim wb As Workbook
Dim ws As Worksheet
Dim bFlag As Boolean
bFlag = False
'You only need one of the two following lines - 1st if it's already open,
2nd if it isn't
Set wb = Workbooks("Raw.xls")
Set wb = Workbooks.Open("C:\path\Raw.xls")
For Each ws In wb.Worksheets
If ws.Name = "Cat" Then bFlag = True
Next ws
If bFlag = False Then
Set ws = wb.Worksheets.Add
ws.Name = "Cat"
End If
End Sub
"Ranjith Kurian" wrote:
Hi,
i hv a excel workbook called as Raw.xls, i need a macro code to check in
Raw.xls whether the sheet name 'Cat' is there, if not there then the macro
need to add a new sheet called as 'Cat'
|