Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copying A Worksheet From Each Open Workbook to an new Workbook | Excel Worksheet Functions | |||
Copying to Workbook depending on Criteria? | New Users to Excel | |||
Hiding/Exposing Worksheets based on a Number Entry | Excel Discussion (Misc queries) | |||
Worksheets Vanishing in Shared Workbook. | Excel Discussion (Misc queries) | |||
Viewing Worksheets withing One Workbook | New Users to Excel |