Nikhil J Shriyan
New Member
- Joined
- May 27, 2012
- Messages
- 15
- Office Version
- 365
- Platform
- Windows
Hello ,
I had this macro to combine Sheets in excel together which used to work in Excel 2007 but this is not working in excel 365. Does anybody Help me.
I want to Merge Excel sheets from the same Excel Together in One Sheet.
I had this macro to combine Sheets in excel together which used to work in Excel 2007 but this is not working in excel 365. Does anybody Help me.
I want to Merge Excel sheets from the same Excel Together in One Sheet.
VBA Code:
Sub CombineSheets()
'
' Macro3 Macro
'
'
Sheets.Add(Before:=Sheets(1)).Name = "Master"
Sheets("Master").Activate
'Sub SheetNames()
Columns(1).Insert
For i = 1 To Sheets.Count
Cells(i, 1) = Sheets(i).Name
Next i
'End Sub
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
ActiveWindow.FreezePanes = True
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
'1
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'2
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'3
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'4
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'5
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'6
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'6
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'7
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'8
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'9
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'10
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'11
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'12
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'13
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'14
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'15
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'16
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'17
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'18
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'19
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'20
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'21
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'22
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'23
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'24
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'25
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'26
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
'27
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("Master").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, 0).Select
Selection.End(xlToLeft).Select
If ActiveSheet.Index = Worksheets.Count Then
Worksheets(1).Activate
Else
ActiveSheet.Next.Activate
End If
ActiveWindow.SelectedSheets.Delete
End Sub
Last edited by a moderator: