Hello. Is there any way to create few copies of selected sheet at once? If i need, for example, 50 copies, making “right click on sheet - remove/copy sheet - copy” 50 times is very tiring.
Hello, yes, it’s possible:
Sub CopyActiveSheet
Dim sName As String, sNewName As String, sK As String
Dim oSheets As Variant, i As Long, j As Long, k As Long, m As Long
sK = InputBox("How many copies of the current sheet do you need to create?", "Enter number","2")
k = Val(sK)
If k < 1 Then Exit Sub
sName = ThisComponent.getCurrentController().getActiveSheet().getName()
oSheets = ThisComponent.getSheets()
j = 0
For i = 1 To k
For m = 1 To 100
j = j + 1
sNewName = sName & "_" & j
If Not oSheets.hasByName(sNewName) Then
oSheets.copyByName(sName, sNewName, oSheets.getCount())
Exit For
EndIf
Next m
Next i
End Sub
Thank you, it worked