+ Reply to Thread
Results 1 to 3 of 3

Add New Sheet,named based on cell value VBA problem and "smoother" code

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-11-2009
    Location
    Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    252

    Add New Sheet,named based on cell value VBA problem and "smoother" code

    hello,
    I have a problem with VBA code to copy new sheet named based on cell value
    main sheet= sheet 1.. sheet source= sheet 2 .. new sheet= cell A1 value
    1. if the same name or in cell a1 has not changed ,cause error ..


    If Range("a1").Value = "" Then Exit Sub
    Sheets("sheet2").Visible = True
    Worksheets("sheet2").Copy After:=Worksheets(Worksheets.Count)
    ActiveSheet.Name = Range("a1").Value
    Sheets("sheet2").Visible = False
    Worksheets("sheet1").Activate
    2. is there any similar code that can be run much smoother or faster..?

    thanks for any help
    Last edited by herukuncahyono; 07-09-2013 at 01:59 AM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Add New Sheet,named based on cell value VBA problem and "smoother" code

        If Range("A1").Value = "" Then Exit Sub
        If Evaluate("ISREF('" & Range("A1").Value & "'!A1)") Then Exit Sub 'Test if worksheet name exists
        Application.ScreenUpdating = False
        Worksheets("Sheet2").Copy After:=Worksheets(Worksheets.Count)
        ActiveSheet.Name = Sheets("Sheet1").Range("A1").Value
        ActiveSheet.Visible = True
        Worksheets("Sheet1").Activate
        Application.ScreenUpdating = True
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    03-11-2009
    Location
    Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    252

    Re: Add New Sheet,named based on cell value VBA problem and "smoother" code

    hi AlphaFrog,
    the code running well..& look smoother
    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1