[英]Delete 2 Rows and 2 Columns in VBA
My code is below. 我的代码如下。 I want to delete Rows 81 and 82 and columns F and H. My code below successfully deletes the rows but fails to delete the 2 columns.
我想删除第81和82行以及F和H列。下面的代码成功删除了行,但未能删除2列。 This with block is within a larger Sub.
带块的此块在较大的Sub中。
With Sheets("PDEL_Report 500K")
Rows("81:82").Select
Selection.ClearContents
Selection.Delete Shift:=xlUp
Columns("F:F,H:H").Select
Selection.ClearContents
Selection.EntireColumn.Delete Shift:=xlLeft
End With
With Sheets("PDEL_Report 500K")
.Rows("81:82").EntireRow.Delete Shift:=xlUp
.Columns("H:H").EntireColumn.Delete Shift:=xlLeft 'delete H first so shift does not affect current column F
.Columns("F:F").EntireColumn.Delete Shift:=xlLeft
End With
Try with below 请尝试以下
With Sheets("PDEL_Report 500K")
.Rows("81:82").Delete Shift:=xlUp
.Columns("H:H").EntireColumn.Delete Shift:=xlToLeft
.Columns("F:F").EntireColumn.Delete Shift:=xlToLeft
End With
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.