Results 1 to 8 of 8
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why the macro no rename sheet... (2000 sr -1)

    ... why the macro no rename the sheet already copied whit the value of string "strName"

    Sub TRIMESTRE()

    Dim PRIMO As String
    Dim SECONDO As String
    Dim TERZO As String
    Dim QUARTO As String
    Dim RIGA As String
    Dim DATA_ODIERNA As Date
    Dim TRIMESTRE As String
    Dim ANNO As String

    RIGA = 1

    ANNO = Format(CDate(Now), "YYYY")
    DATA_ODIERNA = Format(CDate(Now), "DD/MM/YYYY")

    While Not Sheets("GRUPPO").Range("G" & RIGA) = ""
    RIGA = RIGA + 1
    If DATA_ODIERNA > Sheets("GRUPPO").Range("H" & RIGA) And DATA_ODIERNA < Sheets("GRUPPO").Range("I" & RIGA) Then
    TRIMESTRE = "I"
    strName = TRIMESTRE & "_TRIMESTRE" & "_" & ANNO
    GoTo CREA
    End If
    RIGA = RIGA + 1
    If DATA_ODIERNA > Sheets("GRUPPO").Range("H" & RIGA) And DATA_ODIERNA < Sheets("GRUPPO").Range("I" & RIGA) Then
    TRIMESTRE = "II"
    strName = TRIMESTRE & "_TRIMESTRE" & "_" & ANNO
    GoTo CREA
    End If
    RIGA = RIGA + 1
    If DATA_ODIERNA > Sheets("GRUPPO").Range("H" & RIGA) And DATA_ODIERNA < Sheets("GRUPPO").Range("I" & RIGA) Then
    TRIMESTRE = "III"
    strName = TRIMESTRE & "_TRIMESTRE" & "_" & ANNO
    GoTo CREA
    End If
    RIGA = RIGA + 1
    If DATA_ODIERNA > Sheets("GRUPPO").Range("H" & RIGA) And DATA_ODIERNA < Sheets("GRUPPO").Range("I" & RIGA) Then
    TRIMESTRE = "IV"
    strName = TRIMESTRE & "_TRIMESTRE" & "_" & ANNO
    GoTo CREA
    End If

    Wend

    CREA:

    Worksheets("L0953_TRIMESTRE").Copy _
    After:=Worksheets(Worksheets.COUNT)
    Set wshTarget = Worksheets(Worksheets.COUNT)
    wshTarget.Name = strName

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Why the macro no rename sheet... (2000 sr -1)

    Click in the line

    wshTarget.Name = strName

    Press F9 to set a breakpoint.
    Run the macro by pressing F5. It will pause at the line with the breakpoint. Move the mouse pointer over the word strName. What is its value?

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why the macro no rename sheet... (2000 sr -1)

    pherpas solved 80%...
    But why the macro no rename TEMPLATE_1 after copy?
    The macro rename other sheet in wbook????

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Why the macro no rename sheet... (2000 sr -1)

    I cannot test the new code since it refers to worksheets that do not exist.

    The original code appeared to work correctly. What exactly was the problem with it?

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why the macro no rename sheet... (2000 sr -1)

    peraphs understand the prob...

    See here: Worksheets.COUNT
    count is upercse COUNT and not count...
    Why? because i have used this var in other code this Var assume the old value...
    How to corret...?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Why the macro no rename sheet... (2000 sr -1)

    That doesn't really matter. Even though it is displayed in upper case, it should still work correctly.

  7. #7
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why the macro no rename sheet... (2000 sr -1)

    Hams sorry me, but in other case not work, help me now! please (module CHIUDI_TRIMESTRE) the macro reneame 1949_singolo)
    http://www.mytempdir.com/1175009

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Why the macro no rename sheet... (2000 sr -1)

    Please reduce the file size and attach it to a post.

Posting Permissions

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