Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Macro to deleting spreadsheets in a workbook

Hey guys
My macro uses a pivottablefunction (zoom value) to extract data. This
pivot-function creates a new sheet in my workbook, and I'm looking for
a methode to make my macro delete this new sheet in the end of the
program, when the extract is copied, placed (pasted) and formatted in
right position.
The problem (my problem) is that the new sheets are automaticly
generated by Excel with new index every time the zoomvalue function is
activated - so I have to make my macro delete all sheets that is named
"sheetxx" (xx is index) - and spare the other ones.

This is certainly a small step to life of Excel-VBA-mankind, but a big
step to make my day :)))


With hopefully regards
Snoopy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to deleting spreadsheets in a workbook

Dim s as String, sh as Worksheet
Application.DisplayAlerts = False
for each sh in worksheets
s = lcase(sh.name)
if len(s) 5 then
if left(s,5) = "sheet" then
sh.Delete
end if
end if
Next
Application.DisplayAlerts = True


--
Regards,
Tom Ogilvy


"Snoopy" wrote in message
ups.com...
Hey guys
My macro uses a pivottablefunction (zoom value) to extract data. This
pivot-function creates a new sheet in my workbook, and I'm looking for
a methode to make my macro delete this new sheet in the end of the
program, when the extract is copied, placed (pasted) and formatted in
right position.
The problem (my problem) is that the new sheets are automaticly
generated by Excel with new index every time the zoomvalue function is
activated - so I have to make my macro delete all sheets that is named
"sheetxx" (xx is index) - and spare the other ones.

This is certainly a small step to life of Excel-VBA-mankind, but a big
step to make my day :)))


With hopefully regards
Snoopy



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
Matching two spreadsheets & deleting "False" matches Lily Excel Discussion (Misc queries) 1 June 10th 08 09:38 PM
Finding and deleting macro in a workbook starguy Excel Discussion (Misc queries) 4 June 23rd 06 11:35 AM
deleting all macro/codes from workbook Shashi Bhosale Excel Programming 1 November 3rd 05 02:54 PM
Deleting links to other spreadsheets KarenH Excel Worksheet Functions 2 October 28th 05 04:09 AM
Deleting a 'workbook' macro chiv Excel Programming 5 May 24th 05 06:41 PM


All times are GMT +1. The time now is 02:33 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"