T3l3cm0:123
New Member
- Joined
- Oct 4, 2013
- Messages
- 2
Im trying to merge worksheets together into one workbook. I have a work book that has over 20 sheets. I has looking to create a macro that would merge sheets together (deepening on their name) into a separate workbook.
So far this is the code that I have got, it mergers all the sheets in the workbook together but I would like to merge them by name.
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;">Sub mergedata()Sheets(1).Activatelastrow = ActiveSheet.UsedRange.Rows.CountFor Each Sheet In SheetsIf Sheet.Index <> 1 ThenRowCount = Sheet.UsedRange.Rows.CountSheet.UsedRange.Copy Destination:=Sheets(1).Cells(lastrow + 1, 1)lastrow = lastrow + RowCountSheet.UsedRange.ClearEnd IfNext SheetEnd Sub</code></pre>
So far this is the code that I have got, it mergers all the sheets in the workbook together but I would like to merge them by name.
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;">Sub mergedata()Sheets(1).Activatelastrow = ActiveSheet.UsedRange.Rows.CountFor Each Sheet In SheetsIf Sheet.Index <> 1 ThenRowCount = Sheet.UsedRange.Rows.CountSheet.UsedRange.Copy Destination:=Sheets(1).Cells(lastrow + 1, 1)lastrow = lastrow + RowCountSheet.UsedRange.ClearEnd IfNext SheetEnd Sub</code></pre>