Question to overwriting a sheet

  • Thread starter Philipp Oberleitner
  • Start date
P

Philipp Oberleitner

I have the error that when i want to execute the macro again i get an error
messsage cause teh sshet already exist , is there a way to overwrite it ?

Sub ShowOpenTickets()
Const Blatt1 = "2004-05-28_Auswertung_D2_VDF"
ActiveWorkbook.Worksheets.Add.Name = "Open Tickets"
Const Blatt2 = "Open Tickets"
Dim i As Integer
Dim iAnz As Integer

Application.ScreenUpdating = False
Sheets(Blatt1).Activate
Range("D1").Select
iAnz = 0
i = 0

Do Until i = ActiveSheet.UsedRange.Rows.Count
If ActiveCell.Value = "in work" Or ActiveCell.Value = "assigned" Then
Selection.EntireRow.Copy
Sheets(Blatt2).Activate
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Select
Sheets(Blatt1).Select
ActiveCell.Offset(1, 0).Select
iAnz = iAnz + 1
Else
ActiveCell.Offset(1, 0).Select
End If
i = i + 1
Loop
Application.CutCopyMode = False
Application.ScreenUpdating = True
MsgBox "Es wurden " & iAnz & " Sätze übertragen"

End Sub
 
H

Harald Staff

Hi Philipp

Sheet names must be unique in a workbook, because you may have formulas
saying
=Open Tickets!A1
So if you have to create a new sheet with this distinct name, you have to
rename the old one to something else first. This "something else" also has
to be unique (... and so on ;-)

HTH. Best wishes Harald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top