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: 56
Default Ron de Bruin's merge cells to master sheet

Hi,

Using Ron de Bruin's code below to copy range from worksheets to one master
sheet, how can I copy just those rows in each range from each page that do
not have a date in the "m" column? I need a summary of action items for
each person that haven't been completed yet. Is this possible?

Thanks in advance for any help.
Pam

Sub CopyRangeFromMultiWorksheets()

Dim sh As Worksheet

Dim DestSh As Worksheet

Dim Last As Long

Dim CopyRng As Range

With Application

..ScreenUpdating = False

..EnableEvents = False

End With

'Delete the sheet "RDBMergeSheet" if it exist

Application.DisplayAlerts = False

On Error Resume Next

ActiveWorkbook.Worksheets("RDBMergeSheet").Delete

On Error GoTo 0

Application.DisplayAlerts = True

'Add a worksheet with the name "RDBMergeSheet"

Set DestSh = ActiveWorkbook.Worksheets.Add

DestSh.Name = "RDBMergeSheet"

'loop through all worksheets and copy the data to the DestSh

For Each sh In ActiveWorkbook.Worksheets

If sh.Name < DestSh.Name Then

'Find the last row with data on the DestSh

Last = LastRow(DestSh)

'Fill in the range that you want to copy

Set CopyRng = sh.Range("A1:G1")

'Test if there enough rows in the DestSh to copy all the data

If Last + CopyRng.Rows.Count DestSh.Rows.Count Then

MsgBox "There are not enough rows in the Destsh"

GoTo ExitTheSub

End If

'This example copies values/formats, if you only want to copy the

'values or want to copy everything look at the example below this macro

CopyRng.Copy

With DestSh.Cells(Last + 1, "A")

..PasteSpecial xlPasteValues

..PasteSpecial xlPasteFormats

Application.CutCopyMode = False

End With

'Optional: This will copy the sheet name in the H column

DestSh.Cells(Last + 1, "H").Resize(CopyRng.Rows.Count).Value = sh.Name

End If

Next

ExitTheSub:

Application.Goto DestSh.Cells(1)

'AutoFit the column width in the DestSh sheet

DestSh.Columns.AutoFit

With Application

..ScreenUpdating = True

..EnableEvents = True

End With

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
Ron de Bruin's Merge - Can I use multiple named ranges?? Andrew P. Excel Programming 11 September 8th 09 06:10 AM
Copy cells & sheet name to master sheet cottage6 Excel Programming 1 April 23rd 08 10:16 PM
Merge cells from all worksheets into a master worksheet pmv464 Excel Discussion (Misc queries) 2 March 29th 08 11:49 PM
Merge cells to master sheet Steve Excel Discussion (Misc queries) 2 December 13th 07 12:04 AM
Overwrite Master sheet when using merge macro Mark Jackson Excel Programming 3 June 8th 05 09:33 AM


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