Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Merging Worksheets


I'll be glad when I can get my head round this.... but until
then I have to rely on you good people!

Further to my question of earlier today, I now have all my worksheets
merging thanks to some much appreciated advice, however, the method I'm
using also merges the data that has been merged into the Master
Worksheet!

Below is my code and what I need is to exclude the Master from the
merge - can this be done? (sorry about all the comments but I find I
need to know what's going on! :) )

Sub ValuesToMaster()

Dim wb As Workbook
Dim wsSrc As Worksheet
Dim wsDst As Worksheet
Dim rgSrc As Range
Dim rgDst As Range

Set wb = ThisWorkbook

'Prevent screen updating
Application.ScreenUpdating = False

'UnProtect Workbook
wb.Unprotect ("deelee")

'Unprotect all worksheets
For Each wsSrc In ThisWorkbook.Sheets
wsDst.Unprotect ("deelee")
Next

'Set destination sheet as 'Master'
Set wsSrc = wb.Worksheets("Master")

'Clean the destination... (leave 2 headerrow)
wsDst.UsedRange.Offset(2).ClearContents

'loop thru an array of sheets
For Each wsSrc In ActiveWorkbook.Worksheets

'find the current region starting at cell A1
Set rgSrc = wsSrc.Cells(1).CurrentRegion

'shift 1 row down to skip the headers.
Set rgSrc = rgSrc.Resize(rgSrc.Rows.Count - 1).Offset(1)

'find the last value in column A on master
Set rgDst = wsDst.Cells(Rows.Count, 1).End(xlUp)

'shift 1 row down and size same as source
Set rgDst = rgDst.Resize( _
rgSrc.Rows.Count, rgSrc.Columns.Count).Offset(1)

'copy the values
rgDst.Value = rgSrc.Value
Next

'Protect all Worksheets in Workbook
For Each wsSrc In ThisWorkbook.Sheets
wsSrc.Protect ("deelee")
Next

'Update Screen
Application.ScreenUpdating = True

End Sub

Once again, thank you for your time, advice and patience

Regards,

Dave


--
deelee
------------------------------------------------------------------------
deelee's Profile: http://www.excelforum.com/member.php...o&userid=34866
View this thread: http://www.excelforum.com/showthread...hreadid=556697

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
merging two worksheets tdart New Users to Excel 1 December 12th 08 02:48 PM
Merging Two Worksheets Stella Excel Worksheet Functions 6 June 26th 08 02:35 AM
Merging worksheets into one Edward Owen Excel Programming 2 May 17th 06 06:50 PM
Merging of Worksheets David Smithz Excel Discussion (Misc queries) 1 March 6th 06 06:51 PM
merging worksheets onto one Doug Excel Programming 2 December 9th 04 07:49 PM


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