+ Reply to Thread
Results 1 to 7 of 7

renaming sheet with a value in a specific cell and editing cells in new sheet

Hybrid View

macgyver72 renaming sheet with a value... 03-29-2013, 08:27 AM
AB33 Re: renaming sheet with a... 03-29-2013, 08:47 AM
macgyver72 Re: renaming sheet with a... 03-30-2013, 07:26 AM
AB33 Re: renaming sheet with a... 03-30-2013, 07:32 AM
macgyver72 Re: renaming sheet with a... 03-30-2013, 08:02 AM
AB33 Re: renaming sheet with a... 03-30-2013, 09:04 AM
macgyver72 Re: renaming sheet with a... 03-30-2013, 10:27 AM
  1. #1
    Registered User
    Join Date
    03-16-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    12

    renaming sheet with a value in a specific cell and editing cells in new sheet

    My macro is below. The script works for the most part except that it gives me the following error "run time error 9 subscript out of range" and it does not rename the sheet with the value in "c13".

    Also, if I do it manually, I can edit values in the new sheet but if I run the macro, the new sheet seems to be formatted as a picture and I can't edit any cells.

    Any help appreciated.

    Thank you.

    Mike




    Sub Macro7()
    '
    ' Macro7 Macro
    '
    
    '
        Range("A1:AB72").Select
        Selection.Copy
        Sheets.Add After:=Sheets(Sheets.Count)
        ActiveSheet.Buttons.Add(600.75, 49.5, 161.25, 59.25).Select
        ActiveSheet.Buttons.Add(602.25, 142.5, 162, 66).Select
        ActiveSheet.Paste
        Range("C13:G13").Select
        Columns("L:L").ColumnWidth = 9.71
        Sheets("Sheet12").Select
        Sheets("Sheet12").Name = "Sheet12"
        Range("C13:G13").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Sheet12").Select
        Sheets("Sheet12").Name = "Pothier Homes    "
        Range("E10").Select
    End Sub

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: renaming sheet with a value in a specific cell and editing cells in new sheet

    Sheets("Sheet12").Name = "Sheet12"
      
        Sheets("Sheet12").Name = "Pothier Homes
    These are two lines which are copying in to names. Where is the line which refers to C13?

  3. #3
    Registered User
    Join Date
    03-16-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: renaming sheet with a value in a specific cell and editing cells in new sheet

    sorry, thought I had replied, the line refers to the second item (pothier homes in this case)

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: renaming sheet with a value in a specific cell and editing cells in new sheet

    Sheets("Sheet12").Name = "Sheet12"
      
     Sheets("Sheet12").Name = "Pothier Homes"
    You are trying to rename the same sheet(sheet12) twice with different names.
    What is in C13?
    May be
    Sheets("Sheet12").Name = Range("C13")

  5. #5
    Registered User
    Join Date
    03-16-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: renaming sheet with a value in a specific cell and editing cells in new sheet

    Here is what I have now. I think part of the issue may be that the sheet number doesn't change (i.e. last tim I ran it, sheet 23 was created but the macro refers to sheet 20.

    Range("A1:AB75").Select
        Selection.Copy
        Sheets.Add After:=Sheets(Sheets.Count)
        Range("A1").Select
        ActiveSheet.Buttons.Add(600.75, 49.5, 161.25, 59.25).Select
        ActiveSheet.Buttons.Add(602.25, 142.5, 162, 66).Select
        ActiveSheet.Paste
        Range("G9").Select
        Columns("L:L").ColumnWidth = 9.29
        Range("C13:G13").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Sheet20").Select
        Sheets("Sheet20").Name = Range("C13")

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: renaming sheet with a value in a specific cell and editing cells in new sheet

    Okay!
    What is now the issue then? You can not use C13 to rename another sheet as you have already used it, unless of course the value of C13 changes as you loop through.

  7. #7
    Registered User
    Join Date
    03-16-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: renaming sheet with a value in a specific cell and editing cells in new sheet

    My setup is as follows: I have a sheet that I call "client quotes" which I reuse all the time. Once I'm done developing a quote, I want to save a copy of that quote as a new sheet and name that sheet with the value that is in c13 (client name). C13 changes everytime I do a new quote.

    Thanks

    Mike

+ 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