?
Solved

Excel Delete Worksheet and cretae new work sheet

Posted on 2014-09-04
3
Medium Priority
?
192 Views
Last Modified: 2014-09-08
Hello Experts Exchange
I need a bit of VB code that will do the following.

Check if there is a worksheet called Import.
If there is a worksheet called import delete it from the excel file.

Regards

SQLSearcher
0
Comment
Question by:SQLSearcher
[X]
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
3 Comments
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 2000 total points
ID: 40303660
Hi,

This code will address your requirements...

Public Sub Q_28511584()
 
  Application.DisplayAlerts = False
  
  On Error Resume Next
  
  Worksheets("Import").Delete
  
  On Error GoTo 0
  
  Application.DisplayAlerts = True
  
End Sub

Open in new window


However, what should happen if the only worksheet within the workbook is called [Import]?
0
 

Author Closing Comment

by:SQLSearcher
ID: 40305358
Thank you very much for your help.
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 40309281
You are very welcome.

Good luck with your project.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

771 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