Announcement

Collapse
No announcement yet.

Rename Sheet Based On Cell

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rename Sheet Based On Cell



    Hi

    i am trying to create a macro that renames a newly created sheet with whatever i paste into A1

    Code:
    Sub Example()
    '
    ' Example Macro
    ' Macro recorded 14/01/2008 by KCHAN
    '
    
    '
        Sheets("Sheet1").Select
        Sheets("Sheet1").Copy After:=Sheets(4)
        Sheets("Data Conversion").Select
        Range("A2").Select
        Selection.Copy
        Sheets("Sheet1 (2)").Select
        Range("A1").Select
        ActiveSheet.Paste
        Sheets("Sheet1 (2)").Select
        Sheets("Sheet1 (2)").Name = "Grapefruit"
        Range("J29").Select
    End Sub
    Grapefruit is what is pasted into cell A1 but as you can see the sheet is renamed grapefruit regardless of what is actually copied.

    Any help is much appreciated

  • #2
    Re: Sheet Renaming Macros

    Hello,

    Maybe changing this line:
    Code:
    Sheets("Sheet1 (2)").Name = "Grapefruit"
    to
    Code:
    Sheets("Sheet1 (2)").Name = Range("A1").Text
    HTH

    JL

    Comment


    • #3


      Re: Sheet Renaming Macros

      Code:
      Sub Example()
          
          Sheets("Sheet1").Copy After:=Sheets(4)
          With Sheets(5)
              Sheets("Data Conversion").Range("A2").Copy .Range("A1")
              .Name = .Range("A1").Value
          End With
      End Sub
      Reafidy

      Forum Rules | Anatomy Of A Good Thread Title | What Have You Tried So Far? | Are You A Cross Poster?

      Comment

      Working...
      X