Tuesday, December 13, 2022

Excel Mind - Auto Create & Rename Multiple Sheets With Just A Click

 Auto Create & Rename Multiple Sheets With Just A Click





Click here for sample File (Download and open in msexcel as it will not work in google sheets)

Copy Below Code and paste it under module:


Sub InsertMultipleSheets()

Dim x As String

Dim ShCnt As Integer

Dim myarray() As String

Dim i As Integer

Dim Lrow As Integer


x = InputBox("Enter number of sheets to insert.", "Enter Multiple Sheets")


If x = NullString Then


Exit Sub


End If


Sheets.Add After:=ActiveSheet, Count:=x


Sheets("Main").Select

Range("A1").Select


Lrow = Range("A1").End(xlDown).Row

ShCnt = ThisWorkbook.Sheets.Count

ReDim myarray(1 To Lrow)

For i = 1 To UBound(myarray)

myarray(i) = Range("A" & i).Value

Next i

For i = 1 To ShCnt

Sheets(i).Name = myarray(i)

Next i

MsgBox "Sheets created and renamed successfully"


End Sub


No comments:

Post a Comment

How To Use Vlookup In Merged Cells

  How To Use Vlookup In Merged Cells Click Here to download sample file for practice Note: Download the file and open with microsoft excel