View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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