Delete selected Range in selected Sheets

JorgenKjer

Board Regular
Joined
Aug 1, 2016
Messages
65
Office Version
  1. 2013
Platform
  1. Windows
Deleteselected Range in selected Sheets


Cananyone help with a code that deletes a Range starting in "A7" to bedeleted in all Sheets except two in the workbook?
Rangecan vary in number of Rows.
Afterall Sheets are deleted, cell "A7" must be active on all sheets thathave been deleted

I'vetried this code but it stops after Case Else with a Run-time error”1004” Selectmethod of Range class failed.

There issurely a better way to choose Rank "A7: K400". I just don't know how.Since only one sheet will have data until Row 400

SubClearLoop()

Dim wscl As Worksheet

For Each wscl In ActiveWorkbook.Worksheets
Select Case wscl.Name
Case "Data", "FrontPage"
' do nothing
Case Else
wscl.Range("A7:K400").Select
Application.CutCopyMode = False
Selection.Clear
Range("A7").Select
End Seleect

Nextwscl

End Sub


RegardsJorgen

 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You actually need to select each page first, if you want to select a cell on it.
Try this:
Code:
Sub ClearLoop()

Dim wscl As Worksheet

For Each wscl In ActiveWorkbook.Worksheets
    Select Case wscl.Name
        Case "Data", "FrontPage"
            ' do nothing
        Case Else
            wscl.Activate
            wscl.Range("A7:K400").Clear
            wscl.Range("A7").Select
    End Select
Next wscl

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top