|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
工作表拆分示例(vsto)
- Private Sub Button2_Click(sender As Object, e As RibbonControlEventArgs) Handles Button2.Click
- Globals.ThisAddIn.Application.ScreenUpdating = False
- Dim arr As Array = Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet.Range("A3:H" & Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet.Range("A65536").End(Excel.XlDirection.xlUp).Row).Value
- Dim DIC As New Dictionary(Of String, String)
- Dim arr_ct As Integer = UBound(arr)
- Dim arr_cvt As Integer = UBound(arr, 2)
- For I As Integer = 1 To arr_ct
- If DIC.ContainsKey(arr(I, 3)) = False Then
- DIC.Add(arr(I, 3), 0)
- End If
- Next
- For Each key In DIC.Keys
- Globals.ThisAddIn.Application.Worksheets.Add.name = key
- Dim sht As Excel.Worksheet = Globals.ThisAddIn.Application.Worksheets(key)
- For j As Integer = 1 To arr_ct
- If arr(j, 3) = key Then
- Dim RW As Integer = sht.Range("A65536").End(Excel.XlDirection.xlUp).Row
- For k As Integer = 1 To arr_cvt
- sht.Cells(RW + 1, k) = arr(j, k)
- Next
- End If
- Next
- Next
- Globals.ThisAddIn.Application.ScreenUpdating = True
- MsgBox("表拆分完成!")
- End Sub
复制代码
工作表拆分for VSTO(源码).rar
(734.44 KB, 下载次数: 127)
|
评分
-
2
查看全部评分
-
|