Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Petitboeuf
 
Posts: n/a
Default Copying worksheets into one workbook... based on content


Dear all

I have 9000 sheets + into a folder and I would like to compile them all
into different workbooks based on the content of cell B2...

So far I have the following code (which works great) but I do not know
how to do multiple IF... or IF within IF...


Code:
--------------------

Sub Compile()

Dim Counter As Long
Dim Source As Workbook
Dim Destination As Workbook

Const MyDir As String = "c:\PromoTrack\MSA\"

Application.ScreenUpdating = False

For Counter = 1 To 9999
Set Source = Workbooks.Open(MyDir & Counter & ".msa")
If Counter = 1 Then
Source.Worksheets.Copy
Set Destination = ActiveWorkbook
ActiveSheet.Name = Counter
Else
Source.Worksheets.Copy After:=Destination.Worksheets(Destination.Workshee ts.Count)
Destination.Worksheets(Destination.Worksheets.Coun t).Name = Counter
End If
Source.Close False
Next

Destination.SaveAs MyDir & "Compilation.xls"

Application.ScreenUpdating = True

MsgBox "Done"

End Sub

--------------------


Where and how would I tell it to check the text content of cell B2 in
each of the sheets and if text=blue then copy else do nothing??

Many thanks for sharing your expertise!!


--
Petitboeuf
------------------------------------------------------------------------
Petitboeuf's Profile: http://www.excelforum.com/member.php...o&userid=10602
View this thread: http://www.excelforum.com/showthread...hreadid=535471

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
Copying A Worksheet From Each Open Workbook to an new Workbook carl Excel Worksheet Functions 1 January 3rd 06 05:37 PM
Copying to Workbook depending on Criteria? Kryptonix New Users to Excel 0 December 12th 05 02:37 PM
Hiding/Exposing Worksheets based on a Number Entry David Excel Discussion (Misc queries) 6 December 11th 05 02:40 AM
Worksheets Vanishing in Shared Workbook. guilbj2 Excel Discussion (Misc queries) 0 November 29th 05 02:42 PM
Viewing Worksheets withing One Workbook cagedbirdflies New Users to Excel 1 February 22nd 05 11:09 PM


All times are GMT +1. The time now is 02:18 PM.

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"