很抱歉,如果这不是一个合适的问题,但我正在寻找可以得到的任何帮助。 “删除行”按钮似乎不适用于我正在使用的Excel文档。
代码是:
Sub Button1_Click()
Dim ws As Worksheet
Dim wb As Workbook
rownumber = InputBox("What row would you like to delete ?")
Set wb = ThisWorkbook
For Each ws In wb.Worksheets
ws.Rows(86).Delete
Next ws
Set wb = Nothing
End Sub
有人可以看到问题吗?非常感谢!
答案 0 :(得分:1)
您的代码正在运行,但是只删除了第86行。
您需要将变量rownumber
传递给Rows().Delete
函数。
尝试一下:
Sub Button1_Click()
Dim ws As Worksheet
Dim wb As Workbook
rownumber = InputBox("What row would you like to delete ?")
Set wb = ThisWorkbook
For Each ws In wb.Worksheets
ws.Rows(rownumber).Delete
Next ws
Set wb = Nothing
End Sub