Sie sind auf Seite 1von 3

Excel Work Book

Formulae No - 01
Formulae Name : VBA Code "Sub GetSheets()"
Use Full for : You can use VBA scripts to combine multiple workbook into one master workbook
_______________________________________________________________________________________
Click Developer > Visual Basic, a new Microsoft Visual Basic for applications window will be
displayed, click Insert > Module, and input the following code into the Module:

Sub GetSheets()
Path = "C:\Users\dt\Desktop\dt kte\"
Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub
___________________________________________________________________________________________________
Tip: In the above code, you can change the path to the one that you are using.
Then click button to run the code, and all of the worksheets (including the blank worksheets
within the workbooks have been merged into the master workbook.

Note: This VBA code can merge the entire workbooks into the master workbook, if you want to
combine specified worksheets of the workbooks, this code will not work.

Any Other Info :


Formulae No - 02
Formulae Name : VBA Code " MakeSummaryTable()"
Use Full for : This will copy all of the C1 cells in all worksheets to column-A in sheet1. Rename the sheet
references per your workbook.

Sub MakeSummaryTable()
Dim ws As Worksheet

Application.ScreenUpdating = False
Sheets("Sheet1").Activate

For Each ws In Worksheets


If ws.Name <> "Sheet1" Then
ws.Range("C1").Copy
ActiveSheet.Paste Range("A65536").End(xlUp).Offset(1, 0)
End If
Next ws

Application.ScreenUpdating = True

End Sub

Any Other Info :


Formulae No - 03
Formulae Name : VBA Code " SortWorkBook()"
Use Full for : Sort Worksheets In Alphabetical / Alphanumeric Order With VBA Code

Sub SortWorkBook()
'Updateby20140624
Dim xResult As VbMsgBoxResult
xTitleId = "KutoolsforExcel"
xResult = MsgBox("Sort Sheets in Ascending Order?" & Chr(10) & "Clicking No will sort
in Descending Order", vbYesNoCancel + vbQuestion + vbDefaultButton1, xTitleId)
For i = 1 To Application.Sheets.Count
For j = 1 To Application.Sheets.Count - 1
If xResult = vbYes Then
If UCase$(Application.Sheets(j).Name) > UCase$(Application.Sheets(j +
1).Name) Then
Sheets(j).Move after:=Sheets(j + 1)
End If
ElseIf xResult = vbNo Then
If UCase$(Application.Sheets(j).Name) < UCase$(Application.Sheets(j +
1).Name) Then
Application.Sheets(j).Move after:=Application.Sheets(j + 1)
End If
End If
Next
Next
End Sub

Das könnte Ihnen auch gefallen