Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Button3_Click()
- Dim wb As Workbook: Set wb = ThisWorkbook
- Dim ws As Worksheet: Set ws = wb.Sheets("Master")
- Dim newws As Worksheet, sh As Worksheet, newname
- Dim query As Long, xst As Boolean, info As String
- retry:
- xst = False
- newname = Application.InputBox("Enter Inmate Name and Number.", info, , , , , , 2)
- If newname = "False" Then Exit Sub
- For Each sh In wb.Sheets
- If sh.Name = newname Then
- xst = True: Exit For
- End If
- Next
- If Len(newname) = 0 Or xst = True Then
- info = "Sheet name is invalid. Please retry."
- GoTo retry
- End If
- ws.Copy after:=ws
- Set newws = ActiveSheet: newws.Name = sh
- End Sub
- Dim wb As Workbook: Set wb = ThisWorkbook
- Dim ws As Worksheet: Set ws = wb.Sheets("Master")
- Dim NewName As String: NewName = ""
- Dim sh As Worksheet
- Retry:
- NewName = Application.InputBox("Enter Inmate Name and Number.", info, NewName, , , , , 2)
- If NewName = "False" Then Exit Sub 'user shoose 'Cancel'
- For Each sh In wb.Sheets
- If NewName = sh.Name Or NewName = "" Then
- MsgBox "Sheet name is invalid. Please retry."
- GoTo Retry
- End If
- Next sh
- ws.Copy After:=ws
- With wb.Sheets("Master (2)")
- .Visible = True
- .Activate
- .Name = NewName
- End With
- Application.ScreenUpdating = false
- ws.visible = xlSheetVisible
- ws.Copy after:=ws
- Set newws = ActiveSheet: newws.Name = sh
- ws.visible = xlsheethidden
- Application.ScreenUpdating = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement