Solved

clear data of sheets except sheets named

Posted on 2013-01-31
3
181 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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Some time ago I was asked to create a VBA function that would calculate a check digit for an input number, using the following procedure: First, sum up all the individual digits in the number If that sum value has more than one digit, then sum up …
Introduction It seems that at least a couple of times per month, I answer a question that requires automating Outlook from another Microsoft Office application, usually (although not always) to send one or more email messages.  For example: …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

772 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