vba 清晰的动态范围vba
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18322170/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 22:50:55 来源:igfitidea点击:
Clear dynamic range vba
提问by xyz
I am trying to clear a dynamic range starting on cell M22 using and going to last column but the use of last column is eluding me.
我试图清除从单元格 M22 开始的动态范围,使用并转到最后一列,但最后一列的使用让我望而却步。
Thanks
谢谢
Sub clear()
Workbooks.Open Filename:=ThisWorkbook.path & "\..\Master Info Page.xlsx"
With Sheets("Sheet1")
lastCol = .Cells(13, .Columns.Count).End(xlToLeft).Column
Lastrow = .Cells(.Rows.Count, lastCol).End(xlUp).Row
End With
Sheets("Sheet1").Range(Cells(M22, 13), Cells(Lastrow, lastCol)).Clear
End Sub
回答by tigeravatar
Couldn't you just do:
你不能只做:
With Sheets("Sheet1")
.Range("M22", .Cells(.Rows.Count, .Columns.Count)).Clear
End With