|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 bavinfeather 于 2019-3-18 11:15 编辑
还是有问题。。正常一个透视表的时候 代码运行正常
透视表的位置变了之后,代码就不能用拉。
我的理解是 For nCol = 2 To i 如果把i 修改成50 那么就不用定义 i 最后一列
直接查找2到50列的所有值,
但是不管是i 还是50 都是只查找到J列。。这是啥原因喃
请下载这个更新后的附件
test_hide.rar
(27.84 KB, 下载次数: 0)
- Sub Button2_Click()
- On Error Resume Next
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim nRow As Integer, nCol As Integer, nFillCol As Integer
-
- i = Cells(6, Columns.Count).End(1).Column
- y = Cells(Rows.Count, 8).End(3).Row
- With Sheet1
-
- For nCol = 2 To i
- If .Cells(6, nCol) = "Sum of FF2" Or .Cells(6, nCol) = "Sum of FF1" Then
- If InStr(Range(Cells(7, nCol), Cells(y, nCol)).NumberFormatLocal, "[ DISCUZ_CODE_0 ]quot;) Then
- Range(Columns(nCol), Columns(nCol)).Select
- Selection.Columns.Group
- Exit For
-
- End If
-
- End If
- Next
- End With
- ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=1
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|