We help IT Professionals succeed at work.

Clear Data Worksheets - Tidy Up Code

lkirke
lkirke asked
on
293 Views
Last Modified: 2012-05-11
Hello Experts,

I have the following code and am always seeking to refine it? Any suggestions on how I cna tidy this up?

Regards

LK
Sub Clear_Contents()

'---> Clears contents from each of the selected sheets
    
If MsgBox("Are you sure you want to import data into the workbook? This will clear within the sheets!!", vbYesNoCancel, "Clear Worksheets!!") = vbYes Then
    Sheets("AREA_1").Select
    Cells.Select
    Selection.ClearContents
    Sheets("AREA_2").Select
    Cells.Select
    Selection.ClearContents
    Sheets("COUNTRY_1").Select
    Cells.Select
    Selection.ClearContents
    Sheets("COUNTRY_2").Select
    Cells.Select
    Selection.ClearContents
    Sheets("COUNTRY_3").Select
    Cells.Select
    Selection.ClearContents
    Sheets("CITY_1").Select
    Cells.Select
    Selection.ClearContents
    Sheets("CITY_2").Select
    Cells.Select
    Selection.ClearContents
    Sheets("CITY_3").Select
    Cells.Select
    Selection.ClearContents
    
    End If

End Sub

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2008
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2008
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thank you Kevin. Both great solutions.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.