Solved

clear data of sheets except sheets named

Posted on 2013-01-31
3
184 Views
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
0
Comment
Question by:Jagwarman
  • 2
3 Comments
 
LVL 13

Expert Comment

by:Shanan212
ID: 38839845
Sub SelectSheet() 
  Dim ws As Worksheet 
  For Each ws In Worksheeets 
 if  ws.name <> "Sheet10" and ws.name <> "Sheet11" then
    Cells.Select
    Selection.Clearcontents
end if
Next ws 

End Sub 

Open in new window

0
 

Author Comment

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

Accepted Solution

by:
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
    Cells.Select
    Selection.ClearContents
    Range("A1").Select
End If
Next ws
MsgBox "Done!"

End Sub

Open in new window


Try this
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

In case Office 2010 has not been deployed in your environment, this article may be quite useful. In our office, we wanted a way to deploy Microsoft Office Professional Plus 2010 through an automated batch file via logon script. This article is docum…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

860 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