作為 PowerQuery 的結果,我在與應用 VBA 宏的另一個表(稱為表 1)相同的作業表上有一個表(稱為表 2)。不幸的是,當宏完成時,每次表 2 的范圍都會擴展為幾個帶有標題的空白列。
如何在 VBA 中處理它 - 最后將行代碼添加到我的當前行以洗掉添加的列?

運行第一個表的宏后表結構中斷:

我建議的代碼結尾部分是
Range("NP_Data_output[[#All],[Column58]:[Column57]]").Select
Selection.ListObject.ListColumns(6).Delete
Selection.ListObject.ListColumns(6).Delete
Selection.ListObject.ListColumns(6).Delete
Selection.ListObject.ListColumns(6).Delete
Selection.ListObject.ListColumns(6).Delete
Selection.ListObject.ListColumns(6).Delete
Selection.ListObject.ListColumns(6).Delete
Selection.ListObject.ListColumns(6).Delete
Selection.ListObject.ListColumns(6).Delete
Selection.ListObject.ListColumns(6).Delete
Selection.ListObject.ListColumns(6).Delete
Selection.ListObject.ListColumns(6).Delete
uj5u.com熱心網友回復:
假設列是保持Column1對Column8
Sub Macro1()
Dim c As ListColumn
For Each c In ActiveSheet.ListObjects("NP_Data_output").ListColumns
If Not c.Name Like "Column[1-8]" Then
c.Delete
End If
Next
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/323730.html
上一篇:如何從作業表中選擇特定列并在excelvba串列框中顯示
下一篇:用戶表單中幾個命令按鈕的唯一代碼
