按鈕Sheet1於Sheets(“Sheet1”) 中:
修改如下:
With Sheets("WW").UsedRange.Offset(1, 0)
執行有問題(請看附件)
按鈕WW於Sheets(“WW”) 中:
With ActiveSheet.UsedRange.Offset(1, 0)
執行 OK (請看附件)
另加入刪除多餘表頭後,再判斷D欄 = “ “,則刪除該列。
AA = Range("A65536").End(xlUp).Row
For i = 6 To AA
If Cells(i, 4) = "" Then
If myi Is Nothing Then
Set myi = Cells(i, 4)
Else
Set myi = Union(myi, Cells(i, 4))
End If
End If
Next
If Not myi Is Nothing Then myi.EntireRow.Delete