From this Code I can Copy the sheet and rename but I cant Copy near to desired (particular) sheet. Or I need to search a sheet already in that workbook to select and copy near to it.
Copy sheet > Copy selected.sheet (Active.Sheet) > Copy before sheet > select required sheet (ActiveSheet.Copy Before:) ask for the sheet
Public Sub CopySheetAndRename()
Dim newName As String
On Error Resume Next
newName = InputBox("Enter the name for the copied worksheet")
If newName <> "" Then
ActiveSheet.Copy After:=Worksheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = newName
End If
End Sub
I Have changed like this but I dont know which portion is wrong or right
Public Sub CopySheetAndRename()
Dim newName As String
On Error Resume Next
newName = InputBox("Enter the name for the copied worksheet")
If newName <> "" Then
On Error Resume Next newName1 = InputBox("Enter the name to copy before worksheet")
If newName1 <> "" Then ActiveSheet.Copy before:=Worksheets(Worksheets(newName1).Index)
On Error Resume Next
ActiveSheet.Name = newName
End If
End Sub
Edited^^^
I need to Change this code as sheet.name or search sheet
ActiveSheet.Copy After:=Worksheets(Sheets.Count)
I Expect the output to copy a sheet with rename and near to a particular Sheet (if there are 3 sheets, say Sheet1, Sheet2 & Sheet3 If I copy a sheet say sheet1 and copy near to sheet say sheet3 then it must copy before sheet3).
ActiveSheet.Copy Before:=ActiveSheet
? – user11246173newname
would be copied sheet? or is it the worksheet AFTER you want to copy? Remember you cannot have 2 worksheets with same name in same workbook – Foxfire And Burns And Burns