|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
求帮忙!怎么将分表更新的内容自动填充到总表,而且分表个数会新增,数量可能有200个,如果用公式的话,应该会很卡吧。
还有就是需要将分表名称自动更新到目录的订单目录列里,并有链接。
直接套用了别人的代码,发现跑不动的,本人对VBA编程又完全不懂
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim r%, ml As Worksheet
Set ml = Sheets("目录")
ml.Range("a:a").ClearContents
ml.Range("a1") = "目录"
r = 1
For Each Sh In ThisWorkbook.Sheets
If Sh.Name <> "目录" Then
r = r + 1
ml.Hyperlinks.Add anchor:=ml.Cells(r, 1), Address:="", SubAddress:="'" & Sh.Name & "'!a1", TextToDisplay:=Sh.Name
Sh.Hyperlinks.Add anchor:=Sh.Cells(1, 8), Address:="", SubAddress:="'目录'!a1", TextToDisplay:="返回目录"
With Sh.Cells(1, 15).Font
.Name = "微软雅黑"
.Size = 12
.Underline = xlUnderlineStyleNone
End With
End If
Next Sh
With ml.Range("a1").CurrentRegion
With .Font
.Name = "微软雅黑"
.Size = 12
.Underline = xlUnderlineStyleNone
End With
.HorizontalAlignment = xlLeft
End With
ml.Columns.AutoFit
End Sub
|
|