Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
I found the following post for Merging Excel worksheets and after I added
the Array statement it works great for my application except for one minor problem. I have to crate this report on a monthly basis and all three of the worksheets do not exist every month. I no there has to be a way to attach a statement that checks to see that each tab exists before proceeding or existing the macro becasue of an error. Could someone please help? Sub MergeSheets() ' Merges data from all the selected worksheets onto the end of the ' active worksheet. Const NHR = 1 'Number of header rows to not copy from each MWS Sheets(Array("RAY517", "RAY518, RAY519")).Select Sheets("RAY517").Activate Dim MWS As Worksheet 'Worksheet to be merged Dim AWS As Worksheet 'Worksheet to which the data are transferred Dim FAR As Long 'First available row on AWS Dim LR As Long 'Last row on the MWS sheets Set AWS = ActiveSheet For Each MWS In ActiveWindow.SelectedSheets If Not MWS Is AWS Then FAR = AWS.UsedRange.Cells(AWS.UsedRange.Cells.Count).Row + 1 LR = MWS.UsedRange.Cells(MWS.UsedRange.Cells.Count).Row MWS.Range(MWS.Rows(NHR + 1), MWS.Rows(LR)).Copy AWS.Rows(FAR) End If Next MWS End If Joe |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Merging adjacent repeated columns with a macro | Excel Discussion (Misc queries) | |||
Merging from one worksheet to another | Excel Discussion (Misc queries) | |||
merging two worksheet | Excel Worksheet Functions | |||
Merging worksheet data | Excel Discussion (Misc queries) | |||
Keep Format After Merging Worksheets Using CopyFromWorksheet Macro | Excel Discussion (Misc queries) |