View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan Drummond[_3_] Rowan Drummond[_3_] is offline
external usenet poster
 
Posts: 414
Default Does Sheet exist? If True Use If False Create

try:

Sub addsht()
Dim prnt As Worksheet
On Error Resume Next
Set prnt = Sheets("Print")
On Error GoTo 0
If Not prnt Is Nothing Then
'do whatever with prnt eg prnt.activate
Else
Set prnt = Sheets.Add
prnt.Name = "Print"
'do the rest
End If
End Sub

Hope this helps
Rowan

Shake wrote:
When my macro prints addresses from my form i create a sheet called
'print'. I then scale the sheet to A6 size - landscape - paste the data
i need into this sheet and then print the record.

What i need is the VBA code for Checking to see if this sheet exists
already. If it does then i would like to use it. If not i need to
create it.

i.e. If activesheet.("print")=true Then If False - not sure
Call insertData

End If
Set NewSheet = Worksheets.Add
NewSheet.Name = "Print"
Call InsertData

I know the code above in nonsense but it should help the Macro guru's
come up with the cunning solution to my problem, hopefully.