Hi can someone help me with this code. I am trying delete pages in multipage with diferent names and renaming them back.
this code works fine but only when page name is "pozice" + number
when i have pages pozice1, pozice2, pozice3, pozice4 then for example delete page pozice2 it will change name of pozice3 to pozice2 and name of pozice4 to pozice3
but id like to change it so it will delete pages with diferent names.X1, Y2, X3, Y4, Y5 and so on. This code works fine when i delete last page but when i delate page in middle for example Y2 it will make it as X1, X3, Y4 and so on. instead of X1, X2, Y3, Y4
Can someone help me with this? i think problem is when i click delete page it will lose value of (i)
this code works fine but only when page name is "pozice" + number
when i have pages pozice1, pozice2, pozice3, pozice4 then for example delete page pozice2 it will change name of pozice3 to pozice2 and name of pozice4 to pozice3
VBA Code:
Private Sub btndeletepage_Click()
Dim i As Integer
With Me.multipage1
If .Pages.Count > 1 Then
.Pages.Remove .Value
If .Pages.Count > 0 Then
For i = .Value To .Pages.Count - 1
.Pages(i).Caption = "pozice " & i + 1
Next i
End If
Else
MsgBox " Nemůžeš vymazat všechny pozice "
End If
End With
Application.DisplayAlerts = False
If i <> 0 Then
Sheets("výpočet" & i + 1).Delete
End If
Application.DisplayAlerts = True
End Sub
but id like to change it so it will delete pages with diferent names.X1, Y2, X3, Y4, Y5 and so on. This code works fine when i delete last page but when i delate page in middle for example Y2 it will make it as X1, X3, Y4 and so on. instead of X1, X2, Y3, Y4
Rich (BB code):
VBA Code:
Private Sub btndeletepage_Click()
Dim i As Integer
Dim ci As Integer
With Me.multipage1
If .Pages.Count > 1 Then
.Pages.Remove .Value
If .Pages.Count > 0 Then
If .Pages(i).Caption = "Obdelník" & i Then
For i = .Value To .Pages.Count - 1
.Pages(i).Caption = "Obdelník " & i + 1
Next i
ElseIf .Pages(i).Caption = "Mezikruží" & i Then
For i = .Value To .Pages.Count - 1
.Pages(i).Caption = "Mezikruží " & i + 1
Next i
End If
'ci = multipage1.Pages.Count
Application.DisplayAlerts = False
'Sheets("calc" & i + 1).Delete
Application.DisplayAlerts = True
End If
Else
MsgBox " Nemůžeš vymazat všechny pozice "
End If
End With
End Sub
/CODE]