VBA Macro - Convert the "Excel Sheet Column" name into the "new tab"

fahadalambd

New Member
Joined
Sep 16, 2022
Messages
31
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone,

Hope you guys are well. I need a VBA Macro Script which will automatic convert the "Excel Sheet Column" name into the "new tab".

For example, I have 5 columns - column1, column2, column3, column4, column5. I need a VBA script which will convert these columns into the 5 new tab.

Please check the attached screen-shot.

Thanks in advance. :)
 

Attachments

  • Capture.PNG
    Capture.PNG
    14.3 KB · Views: 10

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi everyone,

Hope you guys are well. I need a VBA Macro Script which will automatic convert the "Excel Sheet Column" name into the "new tab".

For example, I have 5 columns - column1, column2, column3, column4, column5. I need a VBA script which will convert these columns into the 5 new tab.

Please check the attached screen-shot.

Thanks in advance. :)
I believe you mean you have 5 cells in column A
And want a new sheet made with the values in Range("A1:A5")
Is that correct?
 
Upvote 0
Maybe this way...assuming your sheet with the names is called "Sheet1"....change to suit
VBA Code:
Sub MM1()
Dim r As Long
For r = 1 To Cells(Rows.Count, "A").End(xlUp).Row
    Worksheets.Add
    ActiveSheet.Name = Sheets("Sheet1").Range("A" & r).Value
Next r
End Sub
 
Upvote 0
Try this:
VBA Code:
'Modified 11/2/2022  9:00:21 PM  EST
Application.ScreenUpdating = False
Dim i As Long
Dim sn As String

Dim Lastrow As Long
Dim ans As String
ans = ActiveSheet.Name
Lastrow = Sheets(ans).Cells(Rows.Count, "A").End(xlUp).Row

    For i = 1 To Lastrow
        sn = Sheets(ans).Cells(i, 1).Value
        Sheets.Add(After:=Sheets(Sheets.Count)).Name = sn
    Next
    Application.Goto Sheets(ans).Range("A1")

Application.ScreenUpdating = True
End Sub
 
Upvote 0
Another option
VBA Code:
Sub fahadalambd()
   Dim Cl As Range
   
   Application.ScreenUpdating = False
   With ActiveSheet
      For Each Cl In .Range("A1", .Range("A" & Rows.Count).End(xlUp))
         If Not Evaluate("isref('" & Cl.Value & "'!A1)") Then
            Sheets.Add(, Sheets(Sheets.Count)).Name = Cl.Value
         End If
      Next Cl
      .Select
   End With
End Sub
 
Upvote 0
Solution
Try this:
VBA Code:
'Modified 11/2/2022  9:00:21 PM  EST
Application.ScreenUpdating = False
Dim i As Long
Dim sn As String

Dim Lastrow As Long
Dim ans As String
ans = ActiveSheet.Name
Lastrow = Sheets(ans).Cells(Rows.Count, "A").End(xlUp).Row

    For i = 1 To Lastrow
        sn = Sheets(ans).Cells(i, 1).Value
        Sheets.Add(After:=Sheets(Sheets.Count)).Name = sn
    Next
    Application.Goto Sheets(ans).Range("A1")

Application.ScreenUpdating = True
End Sub
Thank you so much buddy. IT is working. Thanks for your help :)
 
Upvote 0
Another option
VBA Code:
Sub fahadalambd()
   Dim Cl As Range
  
   Application.ScreenUpdating = False
   With ActiveSheet
      For Each Cl In .Range("A1", .Range("A" & Rows.Count).End(xlUp))
         If Not Evaluate("isref('" & Cl.Value & "'!A1)") Then
            Sheets.Add(, Sheets(Sheets.Count)).Name = Cl.Value
         End If
      Next Cl
      .Select
   End With
End Sub
Thank you so much. You save my life. Thanks again :)
 
Upvote 0
Maybe this way...assuming your sheet with the names is called "Sheet1"....change to suit
VBA Code:
Sub MM1()
Dim r As Long
For r = 1 To Cells(Rows.Count, "A").End(xlUp).Row
    Worksheets.Add
    ActiveSheet.Name = Sheets("Sheet1").Range("A" & r).Value
Next r
End Sub
Maybe this way...assuming your sheet with the names is called "Sheet1"....change to suit
VBA Code:
Sub MM1()
Dim r As Long
For r = 1 To Cells(Rows.Count, "A").End(xlUp).Row
    Worksheets.Add
    ActiveSheet.Name = Sheets("Sheet1").Range("A" & r).Value
Next r
End Sub
Thank you so much mate. You are so genius. Really appreciate for your help :)
 
Upvote 0

Forum statistics

Threads
1,215,112
Messages
6,123,162
Members
449,099
Latest member
afishi0nado

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top