Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Select specific worksheets & copy - code problem

Hi All
I've tried to write the following code to:
- find worksheets in active workbook with "Planned" in cell A1,
- then select all those worksheets and copy them into one new workbook
- then format each sheet within the new workbook (e.g. select a named range
& copy/paste values etc)

The workbook and worksheet names are dynamic

I'm sure I've got the "End If"'s / "Next" in the wrong place (this always
confuses me)
At the moment it copies the active worksheet (which does not have "Planned"
in cell A1) and a blank new worksheet? - and then it stops.
Any help would be greatly appreciated

Sub Selectplanned()
Dim sh As Worksheet
Dim Rng As Range
Application.ScreenUpdating = False
Application.EnableEvents = False

For Each sh In ActiveWorkbook.Worksheets
If sh.Name < "Overview Template" And sh.Name < "GRP Wkly Collection"_
And sh.Name < "GRP Qtrly Collection" And sh.Visible = True Then

On Error Resume Next
Set Rng = sh.Range("A1") = "Planned"
On Error GoTo 0
If Rng Is Nothing Then
Else
Sheets.Select
End If
End If
Next sh
ActiveWindow.SelectedSheets.Copy

For Each sh In ActiveWorkbook.Worksheets
Application.Goto Reference:="Plannedrange"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.Goto Reference:="GRPpost"
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
'etc. etc.
Next sh
End Sub

--
BeSmart
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Select specific worksheets & copy - code problem

Hi
If you want to copy a sheet with "Planned" in A1 do this

If sh.Range("A1").Value = "Planned" then
sh.Copy
end if

Your code is a bit higgledy-piggledy after that. You don't seem to
paste the sheet anywhere within the same loop and then you seem to
start selecting other things in another loop.
Sorry to not be more help!
regards
Paul
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Select specific worksheets & copy - code problem

Thanks Paul - that solved part of my problem...
i.e. worksheets that have "planned" entered into A1 were copied....
but they copied into separate workbooks??
How do I get them to all copy into one new workbook?

FYI
The second part of the code "clears out" functionality that is not required
in the new workbook
e.g.
- Formulas that lookup named ranges in the original workbook
(i.e. copy / paste values into same cells to clear the formula)

- Macro buttons where the macro lives in the original workbook
(i.e. delete specific buttons)

- Named ranges that live in the original workbook & cause "link" errors
(i.e. delete named ranges that are not "local" to this worksheet)

--
Thank for your help
BeSmart


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
Select specific sheets and copy to new workbook jeremiah Excel Programming 2 January 28th 09 04:08 PM
Select any row, copy data from specific columns TexWolf Excel Programming 2 August 3rd 07 09:12 PM
select specific cells and consolidate same over many worksheets MikeR-Oz New Users to Excel 2 March 18th 06 01:27 PM
find specific data in row and select and copy entirerow Junior728 Excel Programming 3 August 8th 05 01:31 PM


All times are GMT +1. The time now is 02:23 AM.

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"