Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Delete Sheets to the left

Since I didn't really want to delete sheets I only tested with
sheets(i).select
MY BAAD!

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Chip Pearson" wrote in message
...
For i = ms To sc
Sheets(i).Delete
Next i


Did you test that code? It doesn't work because 'i' will go past
Sheet.Count midway through the loop.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"Don Guillett" wrote in message
...
This should delete sheets to the right of the active sheet.

Sub delshtsbyindex()
sc = Sheets.Count
'MsgBox sc
ms = ActiveSheet.Index
'MsgBox ms
For i = ms To sc
Sheets(i).Delete
'MsgBox Sheets(i).Name
Next i
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"ian bartlett" wrote in message
news:uSVwk.152886$nD.140587@pd7urf1no...
Hi All

I add sheets through code, and when I have printed what I want I want to
delete all sheets except the two on the left in this case Sheet1(Sheet2)
and Sheet5(Sheet1) doing it with the recorder I got the following, but
this will not work after rebuilding the sheets.

Any ideas ??

Thanks Bart


Sheets("D3").Select
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets(Array("D3", "5", "ATC", "CRU", "AA", "8", "DVJ", "DVH", "1",
"DVG", "ISA", "3", "2", _
"ISC", "7", "ISD", "D4", "9", "D2", "DVF", "4", "ISE", "ISB",
"6", "DVK")).Select
Sheets("D3").Activate
Sheets(Array("10", "12", "3M", "ADM", "180", "PX3", "HOME",
"UAL")).Select Replace:= _
False
Sheets(Array("D3", "5", "ATC", "CRU", "AA", "8", "DVJ", "DVH", "1",
"DVG", "ISA", "3", "2", _
"ISC", "7", "ISD", "D4", "9", "D2", "DVF", "4", "ISE", "ISB",
"6", "UAL")).Select
Sheets("UAL").Activate
Sheets(Array("DVK", "10", "12", "3M", "ADM", "180", "PX3",
"HOME")).Select Replace:= _
False
ActiveWindow.SelectedSheets.Delete
Range("F6").Select




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
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 1 June 22nd 05 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:16 PM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:11 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
delete all text to the left of??? Sheila Excel Worksheet Functions 3 January 25th 05 05:30 PM


All times are GMT +1. The time now is 10:46 AM.

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

About Us

"It's about Microsoft Excel"