Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default exclude hidden worksheets while merging.

I want to exclude hidden worksheets in a workbook from a merge along
with an existing summary sheet. Can anyone help with most practical
statement?
This is the code for excluding the summary sheet.


'Start loop

For Each sht In wrk.Worksheets
'If worksheet in loop is the last one, stop execution
If sht.Index = wrk.Worksheets.Count Then
Exit For
End If

If sht.Name < Sheet1.Name Then

' copy the data
Set rng = sht.Range(sht.Cells(2, 1), sht.Cells(65536, 1).End
(xlUp).Offset(-1).Resize(, colCount))
mst.Cells(65536, 1).End(xlUp).Offset(1).Resize(rng.Rows.Count,
rng.Columns.Count).Value = rng.Value


End If
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default exclude hidden worksheets while merging.


For Each sht In wrk.Worksheets

If sht.Name < Sheet1.Name Then
if sht.Visible = xlSheetVisible THEN

' copy the data
Set rng = sht.Range(sht.Cells(2, 1), sht.Cells(65536, 1).End
(xlUp).Offset(-1).Resize(, colCount))
mst.Cells(65536,
1).End(xlUp).Offset(1).Resize(rng.Rows.Count,
rng.Columns.Count).Value = rng.Value

End If


End If
Next

I'm not sure why you have this
If sht.Index = wrk.Worksheets.Count Then
as your loop will look at each sheet





"dhermus" wrote in message
...
I want to exclude hidden worksheets in a workbook from a merge along
with an existing summary sheet. Can anyone help with most practical
statement?
This is the code for excluding the summary sheet.


'Start loop

For Each sht In wrk.Worksheets
'If worksheet in loop is the last one, stop execution
If sht.Index = wrk.Worksheets.Count Then
Exit For
End If

If sht.Name < Sheet1.Name Then

' copy the data
Set rng = sht.Range(sht.Cells(2, 1), sht.Cells(65536, 1).End
(xlUp).Offset(-1).Resize(, colCount))
mst.Cells(65536, 1).End(xlUp).Offset(1).Resize(rng.Rows.Count,
rng.Columns.Count).Value = rng.Value


End If


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
Exclude Hidden Row Values Dewayne Excel Worksheet Functions 4 January 1st 10 05:22 PM
Exclude hidden sheets from formatting Bart[_8_] Excel Programming 2 September 29th 08 05:32 PM
Copy Worksheet and Exclude Hidden fields Charles Gonzalez Excel Worksheet Functions 3 August 12th 08 12:31 AM
Exclude hidden workbooks from list Duke Carey Excel Programming 3 December 22nd 05 02:40 PM
Exclude hidden data from summary totals XVOTE Excel Discussion (Misc queries) 2 June 3rd 05 05:26 AM


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