ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Does Sheet exist? If True Use If False Create (https://www.excelbanter.com/excel-programming/344980-does-sheet-exist-if-true-use-if-false-create.html)

Shake[_5_]

Does Sheet exist? If True Use If False Create
 

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.


--
Shake
------------------------------------------------------------------------
Shake's Profile: http://www.excelforum.com/member.php...o&userid=28577
View this thread: http://www.excelforum.com/showthread...hreadid=483011


Rowan Drummond[_3_]

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.



Shake[_6_]

Does Sheet exist? If True Use If False Create
 

Rowan Drummond you are indeed an Excel Guru.

Thank You


--
Shake
------------------------------------------------------------------------
Shake's Profile: http://www.excelforum.com/member.php...o&userid=28577
View this thread: http://www.excelforum.com/showthread...hreadid=483011



All times are GMT +1. The time now is 04:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com