在excel中创建sheet的索引 Use index sheets to quickly navigate in an Excel workbook

1. 在最前面创建一个新的sheet

2. 右击sheet,选择 view code

3. 输入下面的代码

4. Alt + Q 返回并保存excel

原文来自: Use index sheets to quickly navigate in an Excel workbook

http://www.techrepublic.com/article/use-index-sheets-to-quickly-navigate-in-an-excel-workbook/5629983

By Mary Ann Richardson
March 22, 2005, 4:40pm PST

Whenworking with large workbooks in Microsoft Excel, you can spend a good deal oftime navigating through dozens of sheet name tabs to find the one you need. Onemethod for making this task easier is to build an index sheet that containshyperlinks to every worksheet in your workbook.

Tocreate the index, follow these steps:

1.       Inserta new worksheet at the beginning of your workbook and rename it Index.

2.       Right-clickon the sheet tab and select View Code.

3.       Enterthe following code below

4.       Press[Alt][Q] and save the workbook.

Thenext time you open the workbook, the Index sheet will contain a list ofhyperlinks to each worksheet in the workbook. Each worksheet also contains ahyperlink back to the Index sheet. In this example, the link back to the Indexis contained in cell H1, but it can be in any cell that is blank for allworksheets.

Private Sub Worksheet_Activate()
Dim wSheet As Worksheet
Dim M As Long
M = 1
    With Me
        .Columns(1).ClearContents
        .Cells(1, 1) = "INDEX"
        .Cells(1, 1).Name = "Index"
    End With
    
    For Each wSheet In Worksheets
        If wSheet.Name <> Me.Name Then
        M = M + 1
        With wSheet
            .Range("H1").Name = "Start" & wSheet.Index
            .Hyperlinks.Add Anchor:=.Range("H1"), Address:="", SubAddress:="Index", TextToDisplay:="Back to Index"
        End With
            Me.Hyperlinks.Add Anchor:=Me.Cells(M, 1), Address:="", SubAddress:="Start" & wSheet.Index, TextToDisplay:=wSheet.Name
        End If
        Next wSheet
End Sub


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用C#的Microsoft.Office.Interop.Excel库来操作Excel工作簿,使用该库可以在Excel插入图片。以下是示例代码: ```csharp using Excel = Microsoft.Office.Interop.Excel; using System.Drawing; // 创建Excel应用程序对象 Excel.Application excelApp = new Excel.Application(); // 打开工作簿 Excel.Workbook workbook = excelApp.Workbooks.Open("D:\\example.xlsx"); // 获取第一个工作表 Excel.Worksheet worksheet = workbook.Sheets[1]; // 插入图片 Image image = Image.FromFile("D:\\example.jpg"); Excel.Range range = worksheet.Range["A1"]; range.Select(); worksheet.Shapes.AddPicture("D:\\example.jpg", Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, range.Left, range.Top, image.Width, image.Height); // 保存并关闭工作簿 workbook.Save(); workbook.Close(); // 退出Excel应用程序 excelApp.Quit(); ``` 以上代码,我们首先使用excelApp对象创建Excel应用程序对象,然后打开需要插入图片的工作簿,获取第一个工作表。接着,我们使用Image.FromFile方法读取图片,然后使用Shapes.AddPicture方法在工作表插入该图片,其,第一个参数为图片的路径,第二个参数表示是否链接到文件,第三个参数表示是否保存图片大小和位置信息,第四个参数和第五个参数表示图片的左上角在工作表的位置,最后两个参数表示图片的宽度和高度。最后,我们保存并关闭工作簿,并退出Excel应用程序。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值