Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Search & Destroy

Always wanted to use that phrase.

Anyways, I have an odd question here. I have a macro that generates a sheet
with numbers, hides it and then creates a plot based off of those numbers in
the hidden sheet. It didn't dawn on me before now that this might be bad. I
just noticed I had about 10 hidden sheets that served no purpose.
I now need a way to remove the hidden sheets if someone removes the graph
that uses that data. Any ideas?

Thanks - Ben H.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Search & Destroy

Hi Ben,

In your sheet generation code, name the hidden sheet and, before creating
the new sheet, delete the named sheet. Something, perhaps like:

'=============
Public Sub Tester()
Dim SH As Worksheet

On Error Resume Next
Application.DisplayAlerts = False
ActiveWorkbook.Worksheets("MyHiddenSheet").Delete
Application.DisplayAlerts = True
On Error GoTo 0

Set SH = ActiveWorkbook.Worksheets.Add
With SH
.Name = "MyHiddenSheet"
.Visible = xlSheetHidden
'your data code
End With

End Sub
'<<=============

Alternatively, dependending upon your requirements, create the hidden sheet
only if it does not already exist, and change the sheet's data when and as
required.


---
Regards,
Norman



"Ben H" wrote in message
...
Always wanted to use that phrase.

Anyways, I have an odd question here. I have a macro that generates a
sheet
with numbers, hides it and then creates a plot based off of those numbers
in
the hidden sheet. It didn't dawn on me before now that this might be bad.
I
just noticed I had about 10 hidden sheets that served no purpose.
I now need a way to remove the hidden sheets if someone removes the graph
that uses that data. Any ideas?

Thanks - Ben H.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Search & Destroy

Norman

The way you explained the method won't work. It won't work because I go
through and delete the chart and sheet with a name before I regenerate the
numbers for that chart and sheet with that same name.

What happens is that Chart "A" links to Sheet "A". The name "A" could be
anything. The user then could delete Chart "A" from the workbook but this
won't catch Sheet "A" since Sheet "A" is hidden. So how do I find Sheet "A"
when the name varies and also when Chart "A" is gone? Is there a way to
search if a cell is linked? Any other ideas?


Thanks - Ben H.

"Norman Jones" wrote:

Hi Ben,

In your sheet generation code, name the hidden sheet and, before creating
the new sheet, delete the named sheet. Something, perhaps like:

'=============
Public Sub Tester()
Dim SH As Worksheet

On Error Resume Next
Application.DisplayAlerts = False
ActiveWorkbook.Worksheets("MyHiddenSheet").Delete
Application.DisplayAlerts = True
On Error GoTo 0

Set SH = ActiveWorkbook.Worksheets.Add
With SH
.Name = "MyHiddenSheet"
.Visible = xlSheetHidden
'your data code
End With

End Sub
'<<=============

Alternatively, dependending upon your requirements, create the hidden sheet
only if it does not already exist, and change the sheet's data when and as
required.


---
Regards,
Norman



"Ben H" wrote in message
...
Always wanted to use that phrase.

Anyways, I have an odd question here. I have a macro that generates a
sheet
with numbers, hides it and then creates a plot based off of those numbers
in
the hidden sheet. It didn't dawn on me before now that this might be bad.
I
just noticed I had about 10 hidden sheets that served no purpose.
I now need a way to remove the hidden sheets if someone removes the graph
that uses that data. Any ideas?

Thanks - Ben H.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot destroy Word Object in Excel dai50 Excel Programming 3 June 29th 06 12:11 PM
Search and destroy Pugwyrm Excel Programming 4 February 14th 05 03:13 PM
Destroy command button with a Macro? grasping@straws Excel Discussion (Misc queries) 3 December 22nd 04 02:30 PM
How to make VBA code to self-destroy itself? count Excel Programming 6 November 10th 04 05:11 PM
Seek and destroy [email protected] Excel Programming 7 December 3rd 03 08:41 PM


All times are GMT +1. The time now is 02:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"