clear data of sheets except sheets named

Posted on 2013-01-31
Last Modified: 2013-01-31
Can someone provide me with VBA code that will clear all data off all sheets exc ept sheets names Sheet10 and Sheet 11

thank you
Question by:Jagwarman
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 13

Expert Comment

ID: 38839845
Sub SelectSheet() 
  Dim ws As Worksheet 
  For Each ws In Worksheeets 
 if <> "Sheet10" and <> "Sheet11" then
end if
Next ws 

End Sub 

Open in new window


Author Comment

ID: 38839876
I am getting 'Variable not defined' ???
LVL 13

Accepted Solution

Shanan212 earned 500 total points
ID: 38839924
Sub SelectSheet()
  Dim ws As Worksheet
  For Each ws In ActiveWorkbook.Worksheets

 If ws.Name <> "Sheet10" And ws.Name <> "Sheet11" Then
End If
Next ws
MsgBox "Done!"

End Sub

Open in new window

Try this

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
My experience with Windows 10 over a one year period and suggestions for smooth operation
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question