es汉字按拼音首字母排序_java


excel按拼音顺序排序


es汉字按拼音首字母排序_python_02


If you have a large number of worksheets in your Excel workbook, it may be hard to find a specific worksheet. Sorting your worksheet tabs alphabetically would make it easier to find what your looking for.

如果您的Excel工作簿中有大量工作表,则可能很难找到特定的工作表。 按字母顺序对工作表选项卡进行排序将使查找所需内容更加容易。

In addition to organizing your worksheet tabs by applying colors to them, you can also sort them alphabetically or alphanumerically, as long as you’ve applied custom names to your worksheets. Unfortunately, sorting worksheet tabs alphabetically is not built in to Excel, but you can add a macro to your workbook that will allow you to sort your tabs in ascending or descending order. We’ll show you how to add a macro available on Microsoft’s support site to your Excel workbook that will sort your worksheet tabs.

除了通过将颜色应用于表来组织工作表标签之外,只要您已将自定义名称应用于工作表,还可以按字母或字母数字顺序对其进行排序。 不幸的是,Excel中没有内置按字母顺序排序工作表选项卡的功能,但是您可以在工作簿中添加一个宏,该宏将允许您按升序或降序对选项卡进行排序。 我们将向您展示如何将Microsoft支持网站上可用的宏添加到Excel工作簿中,以对工作表标签进行排序。


es汉字按拼音首字母排序_excel_03


To begin, press Alt+F11 to open the Microsoft Visual Basic for Applications (VBA) editor. Then, go to Insert > Module.

首先,请按Alt + F11打开Microsoft Visual Basic应用程序(VBA)编辑器。 然后,转到“插入”>“模块”。


es汉字按拼音首字母排序_es汉字按拼音首字母排序_04


Copy and paste the following macro from Microsoft into the module window that displays.

将以下宏从Microsoft复制并粘贴到显示的模块窗口中。

Sub Sort_Active_Book()
Dim i As Integer
Dim j As Integer
Dim iAnswer As VbMsgBoxResult
'
' Prompt the user as which direction they wish to
' sort the worksheets.
'
   iAnswer = MsgBox("Sort Sheets in Ascending Order?" & Chr(10) _
     & "Clicking No will sort in Descending Order", _
     vbYesNoCancel + vbQuestion + vbDefaultButton1, "Sort Worksheets")
   For i = 1 To Sheets.Count
      For j = 1 To Sheets.Count - 1
'
' If the answer is Yes, then sort in ascending order.
'
         If iAnswer = vbYes Then
            If UCase$(Sheets(j).Name) > UCase$(Sheets(j + 1).Name) Then
               Sheets(j).Move After:=Sheets(j + 1)
            End If
'
' If the answer is No, then sort in descending order.
'
         ElseIf iAnswer = vbNo Then
            If UCase$(Sheets(j).Name) < UCase$(Sheets(j + 1).Name) Then
               Sheets(j).Move After:=Sheets(j + 1)
            End If
         End If
      Next j
   Next i
End Sub

The VBA editor automatically names each module with a number on the end, such as Module1, Module2, etc. You can simply accept the default name of the module. However, if you plan to add other macros to your workbook, it’s a good idea to rename each module so you know what they are. We’ll rename our module to show you how.

VBA编辑器会自动在每个模块的末尾命名一个数字,例如Module1,Module2等。您可以简单地接受模块的默认名称。 但是,如果您打算将其他宏添加到工作簿中,则最好重命名每个模块,以便知道它们是什么。 我们将重命名模块以向您展示如何进行。


es汉字按拼音首字母排序_数据库_05


To rename the module, select the text in the Name box for the module under Properties in the left pane.

要重命名模块,请在左侧窗格中“属性”下的模块的“名称”框中选择文本。


es汉字按拼音首字母排序_python_06


Type a name for the module in the Name box and press Enter. Note that the module name cannot contain spaces.

在名称框中键入模块的名称,然后按Enter。 请注意,模块名称不能包含空格。


es汉字按拼音首字母排序_数据库_07


The name of the module changes in the Modules list under Project in the left pane.

模块的名称在左窗格的“项目”下的“模块”列表中更改。


es汉字按拼音首字母排序_excel_08


Close the VBA editor by going to File > Close and Return to Microsoft Excel.

通过转到文件>关闭并返回到Microsoft Excel,关闭VBA编辑器。


es汉字按拼音首字母排序_excel_09


Now, we’re going to run the macro to sort our tabs. Press Alt+F8 to access the list of macros on the Macro dialog box. Select the macro in the list (in our case there is only one macro), and click “Run”.

现在,我们将运行宏以对选项卡进行排序。 按Alt + F8可以在“宏”对话框中访问宏列表。 在列表中选择宏(在我们的例子中只有一个宏),然后单击“运行”。


es汉字按拼音首字母排序_excel_10


The following dialog box displays, allowing you to choose whether you want to sort your worksheets in ascending or descending order. We want to sort them in ascending order, so we click “Yes”.

将显示以下对话框,您可以选择是否要按升序或降序对工作表进行排序。 我们想按升序对它们进行排序,因此我们单击“是”。


es汉字按拼音首字母排序_java_11


The worksheet tabs are now arranged in alphabetical order.

现在,工作表选项卡按字母顺序排列。


es汉字按拼音首字母排序_java_12


The macro you added is part of your workbook now, but when you save it, you’ll probably see the following dialog box. That’s because you saved your workbook as an .xlsx file, which is a normal Excel workbook format that does not include macros. To include macros in your workbook, and be able to run them, you must save your workbook as a macro-enabled workbook, or an .xlsm file. To do this, click “No” on this dialog box.

您添加的宏现在是工作簿的一部分,但是当您保存它时,您可能会看到以下对话框。 这是因为您将工作簿另存为.xlsx文件,这是不包含宏的普通Excel工作簿格式。 要将宏包含在工作簿中并能够运行它们,必须将工作簿另存为启用了宏的工作簿或.xlsm文件。 为此,请在此对话框上单击“否”。


es汉字按拼音首字母排序_python_13


The Save As dialog box displays. Navigate to where you want to save the macro-enabled workbook, if you’re not already in that folder. Select “Excel Macro-Enabled Workbook (*.xlsm)” from the “Save as type” drop-down list.

显示“另存为”对话框。 如果您还不在该文件夹中,请导航至要保存启用宏的工作簿的位置。 从“另存为类型”下拉列表中选择“ Excel启用宏的工作簿(* .xlsm)”。


es汉字按拼音首字母排序_python_14


Click “Save”.

点击“保存”。


es汉字按拼音首字母排序_java_15


If you don’t save the workbook as a macro-enabled workbook (.xlsm file), the macro you added will be deleted. You might want to delete the .xlsx version of your workbook so you don’t forget to use the .xlsm version of your workbook if you want to add more worksheet tabs and sort them again using the macro. You can always save the workbook as an .xlsx file again if you don’t want to use macros anymore.

如果您不将工作簿另存为启用宏的工作簿(.xlsm文件),则添加的宏将被删除。 您可能想要删除工作簿的.xlsx版本,因此,如果要添加更多工作表选项卡并使用宏再次对其进行排序,请不要忘记使用工作簿的.xlsm版本。 如果您不想再使用宏,则可以始终将工作簿另存为.xlsx文件。

翻译自: https://www.howtogeek.com/280917/how-to-sort-worksheet-tabs-in-alphabetical-order-in-excel/

excel按拼音顺序排序