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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
still having troubles with an Excel Macro saving to C: on Windows 10 5 42
Office.Com /myAccount 9 41
MS Office subscription 11 47
Excel 2013 Power Query 1 46
Have you ever had the experience that you had to follow 10 steps over and over again every time when you need to nicely forward an important email to your manager? Fear no more! With the help of the Quick Steps feature in Outlook 2010, your old chor…
Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now