Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Remove not required sheets


Following are the sheet names containing in workbook:
Sheet1, Temp1, Test1, Check1, Sheet2, Test2, Work2, Pend2


Here if removed digits from sheet names, then:
Sheet1 matches Sheet2
Test1 matches Test2

And non matching names a
Temp1, Check1, Work2, Pend2

So, what i actually need is to delete these all non matching sheet
through vba

+-------------------------------------------------------------------
|Filename: RmvSheets.zip
|Download: http://www.excelforum.com/attachment.php?postid=3670
+-------------------------------------------------------------------

--
ilyaskaz
-----------------------------------------------------------------------
ilyaskazi's Profile: http://www.excelforum.com/member.php...fo&userid=2396
View this thread: http://www.excelforum.com/showthread.php?threadid=39291

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Remove not required sheets

This is crude code (untested). But the idea is to check each worksheet
against all the other sheets.
If no match is found than delete the worksheet.

Dim ws as Worksheet, wsn as String, wsi as Integer, i as integer, x as
integer

For each ws in Activeworkbook.Worksheets
x = 0
wsn = Left(ws.name,len(ws.name)-1)
wsi = ws.Index
for i = 1 to Activeworkbook.Worksheets.Count
if i < wsi then
If Left(Sheets(i).name,len(Sheets(i).name)-1) = wsn
x = 1
end if
next

If x = 0 then
ws.delete
end if
Next

--
steveB

Remove "AYN" from email to respond
"ilyaskazi" wrote
in message ...

Following are the sheet names containing in workbook:
Sheet1, Temp1, Test1, Check1, Sheet2, Test2, Work2, Pend2


Here if removed digits from sheet names, then:
Sheet1 matches Sheet2
Test1 matches Test2

And non matching names a
Temp1, Check1, Work2, Pend2

So, what i actually need is to delete these all non matching sheets
through vba.


+-------------------------------------------------------------------+
|Filename: RmvSheets.zip |
|Download: http://www.excelforum.com/attachment.php?postid=3670 |
+-------------------------------------------------------------------+

--
ilyaskazi
------------------------------------------------------------------------
ilyaskazi's Profile:
http://www.excelforum.com/member.php...o&userid=23969
View this thread: http://www.excelforum.com/showthread...hreadid=392911



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Remove not required sheets


Excellent!!!

I hv checked and working perfect as per my requirement.
thankyou steve

--
ilyaskaz
-----------------------------------------------------------------------
ilyaskazi's Profile: http://www.excelforum.com/member.php...fo&userid=2396
View this thread: http://www.excelforum.com/showthread.php?threadid=39291

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Remove not required sheets

You are very welcome!

--
steveB

Remove "AYN" from email to respond
"ilyaskazi" wrote
in message ...

Excellent!!!

I hv checked and working perfect as per my requirement.
thankyou steve.


--
ilyaskazi
------------------------------------------------------------------------
ilyaskazi's Profile:
http://www.excelforum.com/member.php...o&userid=23969
View this thread: http://www.excelforum.com/showthread...hreadid=392911



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
How do i compare and remove common names from 2 excel work sheets Andrew Excel Worksheet Functions 0 April 8th 10 09:02 AM
VBA Code Required for deleting All Sheets except Sheet1 Ms-Exl-Learner Excel Discussion (Misc queries) 7 November 3rd 09 10:19 AM
need help, want to remove some sheets Newbie80 Excel Worksheet Functions 1 August 8th 05 04:16 PM
How do i remove workbooks no longer required ABE Excel Discussion (Misc queries) 4 December 15th 04 07:48 PM
Remove transition between sheets Johnnyb Excel Programming 3 August 7th 04 02:11 PM


All times are GMT +1. The time now is 07:46 PM.

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"