vba 用于删除 Excel 中所有现有工作表中第一行的宏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27820166/
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-12 05:44:11  来源:igfitidea点击:

Macro to delete the first rows in all existing sheets in Excel

excel-vbavbaexcel

提问by KIMco

I have an excel file with around 300 sheets for which I need to remove the first rows. Could you please suggest VBA code for doing this?

我有一个包含大约 300 张纸的 excel 文件,我需要删除第一行。你能建议这样做的VBA代码吗?

Thanks in advance!

提前致谢!

回答by Sathish Kothandam

Atleast try to post what you have tried.

至少尝试发布您尝试过的内容。

below code will delete 1st in all sheets in active workbook

下面的代码将删除活动工作簿中所有工作表中的第一个

Sub LoopThroughSheets()
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets

     ws.Range("1:1").Delete

    Next ws
End Sub

回答by silentsurfer

Private Sub deleteRows()

    Dim ws As Worksheet

    For Each ws In ThisWorkbook.Sheets
        ws.Range("A1").EntireRow.Delete
    Next ws

End Sub