這篇文章給大家介紹excle表格如何將數(shù)據(jù)拆分成不通的sheet頁(yè),內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。
方城ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來(lái)市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
13先展示最后效果:
代碼如下
Sub CFGZB() Dim myRange As Variant Dim myArray Dim titleRange As Range Dim title As String Dim columnNum As Integer myRange = Application.InputBox(prompt:="請(qǐng)選擇標(biāo)題行:", Type:=8) myArray = WorksheetFunction.Transpose(myRange) Set titleRange = Application.InputBox(prompt:="請(qǐng)選擇拆分的表頭,必須是第一行,且為一個(gè)單元格,如:“姓名”", Type:=8) title = titleRange.Value columnNum = titleRange.Column Application.ScreenUpdating = False Application.DisplayAlerts = False Dim i&, Myr&, Arr, num& Dim d, k For i = Sheets.Count To 1 Step -1 If Sheets(i).Name <> "Sheet1" Then Sheets(i).Delete End If Next i Set d = CreateObject("Scripting.Dictionary") Myr = Worksheets("Sheet1").UsedRange.Rows.Count Arr = Worksheets("Sheet1").Range(Cells(2, columnNum), Cells(Myr, columnNum)) For i = 1 To UBound(Arr) d(Arr(i, 1)) = "" Next k = d.keys For i = 0 To UBound(k) Set conn = CreateObject("adodb.connection") conn.Open "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & ThisWorkbook.FullName Sql = "select * from [Sheet1$] where " & title & " = '" & k(i) & "'" Worksheets.Add after:=Sheets(Sheets.Count) With ActiveSheet .Name = k(i) For num = 1 To UBound(myArray) .Cells(1, num) = myArray(num, 1) Next num .Range("A2").CopyFromRecordset conn.Execute(Sql) End With Sheets(1).Select Sheets(1).Cells.Select Selection.Copy Worksheets(Sheets.Count).Activate ActiveSheet.Cells.Select Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False Next i conn.Close Set conn = Nothing Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
6.
7.
8.
9.
10
11.
12注意:
1)原始數(shù)據(jù)表要從第一行開始有數(shù)據(jù),并且不能有合并單元格;
2)打開工作簿時(shí)需要開啟宏,否則將無(wú)法運(yùn)行代碼。
2、生成目錄
a、新建一個(gè)sheet,名字改為”目錄” 在開發(fā)工具中
Sub createmenu()
For i = 1 To Sheets.Count
Cells(i, 1) = Sheets(i).Name
'Cells(i, 2) = Sheets(i).Cells(2, 2).Value
Next i
End Sub
雙擊下目錄那個(gè)sheet 粘貼并執(zhí)行;
b、增加超鏈接
在sheet1中B2單元格中定義超鏈接函數(shù),錄入=HYPERLINK("#"&A2&"!A1",A2)
c、增加返回目錄
選中所有sheet(目錄除外)在任意一張中選個(gè)空白的單元格輸入 =HYPERLINK(“#目錄!A1”,”返回目錄”)
關(guān)于excle表格如何將數(shù)據(jù)拆分成不通的sheet頁(yè)就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。
當(dāng)前題目:excle表格如何將數(shù)據(jù)拆分成不通的sheet頁(yè)
URL鏈接:http://m.rwnh.cn/article36/jcjspg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站排名、App開發(fā)、、品牌網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)