Clear contents of specific ranges in more than sheet

menajaro
2StarLounger
Posts: 182
Joined: 24 Jan 2019, 10:58

Clear contents of specific ranges in more than sheet

Post by menajaro »

Hello everyone,
I've searched the forum, but did't really findanything about this. I have a workbook which contains 6 sheets
where I would like to put a code that enables me to Clear contents of specific Ranges in more than sheet as shown in the attachment which I have highlighted in yellow
as I want to Clear contents the sheets No 5 & 6 from the second row until the last row that has data.
Thank you in advance for looking at this.
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Clear contents of specific ranges in more than sheet

Post by HansV »

Try this macro:

Code: Select all

Sub ClearRanges()
    Worksheets("sheet1").Range("A8:B27,G8:H12,G17:H40").ClearContents
    Worksheets("sheet2").Range("A8:B27,G8:H12,G17:H40").ClearContents
    Worksheets("sheet3").Range("D11:E15").ClearContents
    Worksheets("sheet4").Range("D11:E15").ClearContents
    Worksheets("sheet5").Range("2:1048576").ClearContents
    Worksheets("sheet6").Range("2:1048576").ClearContents
End Sub
Best wishes,
Hans

menajaro
2StarLounger
Posts: 182
Joined: 24 Jan 2019, 10:58

Re: Clear contents of specific ranges in more than sheet

Post by menajaro »

Thanks a lot Mr. Hans
I appreciated your quick response in giving me the above code.
With my best wishes of good and great luck for you forever