LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default For Each sheet in WkBook problem

Sheets in workbook are A, B, C, D, E, F, G plus the two that are excluded in the code.

Total combined rows with data for all A to G sheets is about 52. (about 7 per sheet.)

If I run SheetsCopy1 I get about 5000 rows copied to Summary sheet, multiple repeats of correct data.

If I run SheetsCopy2 I see each sheet range to copy is properly selected and the Msgbox shows the correct sheet name.

The DeBug.Print lists the proper sheets A to G.

Code is in a standard module, and the downloaded example workbook looks to be German, saved as ...xlsm.

What little tid-bit am I overlooking here?

Thanks,
Howard

Sub SheetsCopy1()
Dim ws As Worksheet
Dim Rng As Range

For Each ws In ThisWorkbook.Sheets

If (ws.Name < "Summary") And (ws.Name < "Begin blad") Then

With ws

ws.Activate
Set Rng = Range("A2", Range("D2").End(xlDown))
Rng.Copy Sheets("Summary").Range("A" & Rows.Count).End(xlUp)(2)

End With

End If

Next
End Sub

Sub SheetsCopy2()
Dim ws As Worksheet
Dim Rng As Range
Dim lRow As Long

For Each ws In ThisWorkbook.Sheets

If (ws.Name < "Summary") And (ws.Name < "Begin blad") Then
'Debug.Print ws.Name
With ws
ws.Activate
Set Rng = Range("A2", Range("D2").End(xlDown))
Rng.Select
MsgBox ws.Name
End With

End If

Next
End Sub
 
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
Update Cell in WKBook 1 From WkBook 2 pattlee Excel Discussion (Misc queries) 2 May 25th 08 01:27 PM
VBA Open Wkbook Disabling Macros Karen53 Excel Programming 9 March 21st 08 08:54 PM
How to link to a single wksheet in a wkbook that has comments RedRobyn Excel Discussion (Misc queries) 1 June 27th 06 07:40 PM
[hlp]: How to copy a sheet to new wkbook and close the var at the end pao_e_vinho[_2_] Excel Programming 2 June 27th 06 06:21 PM
Can changes to a worksheet be applied to all wksheets in wkbook? SandyM Excel Worksheet Functions 1 September 18th 05 06:21 PM


All times are GMT +1. The time now is 12:02 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"