Announcement

Collapse
No announcement yet.

Unconfigured Ad Widget

Collapse

VBA : Rename Modules

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

  • VBA : Rename Modules

    How can you rename the names of the modules in the VB window?

    Ross

  • #2
    Yes. Just select the module and change its name in the properties window.
    Please do not U2U (private message) me directly for questions that should be posted to the forum; any such U2Us will be ignored.

    Comment


    • #3
      Just for fun if you would like a VBA solution here is a little one liner, guess could expand on this idea maybe, add this code to a standard module, and attach a forms command button. Edit to site.

      Jack


      Code:

      Sub myRenameA ()
      ActiveWorkbook.VBProject.VBComponents("Module1").Name = _
      "myNewName"
      End Sub

      Comment


      • #4
        That one might bug so try this, you must add to trusted sources also forgot that bit opps !!!

        Jack

        Sub RenameA()
        On Error Resume Next
        With ActiveWorkbook.VBProject
        .VBComponents("Module1").Name = "NewX"
        End With
        On error goto 0
        theEnd:
        some code
        //
        End Sub

        Comment


        • #5
          Re: VBA : Rename Modules

          Originally posted by Derk
          Yes. Just select the module and change its name in the properties window.
          Derk, read your note on changing a module name, however, when I change Module1 to AddComments and then save , when the macro runs I get a box saying that the -
          test.xls!AddComments macro cannot be found. I have to rename it back to Module 1
          Any Ideas
          Colin J

          Comment


          • #6
            Re: VBA : Rename Modules

            Colin

            What is the actual name of the macro?

            The error message suggests that Excel is looking for a macro called AddComments in workbook test.xls.
            Boo!

            Comment


            • #7
              Re: VBA : Rename Modules

              Norrie, the macro is called AddComments, part code below-

              Option Explicit


              Sub AddComments()



              ' Comments Macro
              ' Macro recorded 30/10/2004 by Colin Johnston ACC
              '
              ' As before, copy and paste to add new codes


              ' Insets Tel Nos.Comment

              Sheets("All Dep").Select
              Range("B1").Select
              Range("B1").AddComment
              Range("B1").Comment.Visible = False
              Range("B1").Comment.Text Text:="Colin Johnston ACC:" & Chr(10) & ""
              Range("B1").Comment.Text Text:= _
              "Red Marks at Top Corner of Cells Indicate a Telephone Number, Hover Mouse over Cell to Reveal" _
              & Chr(10) & ""

              ____________--


              The macro is in Test.xls in module2, when I try to rename Module 2 to something else I get the error
              Colin J

              Comment


              • #8
                Re: VBA : Rename Modules

                It looks like you are trying to call the Module the same name as the Procedure, which should not be done.

                TJ
                Oh dear I need a beer
                Online Motorsport Game

                Comment


                • #9
                  Re: VBA : Rename Modules

                  Isn't it easy when you know how, this has bugged me for ages.
                  Thanks TJ.
                  Colin J

                  Comment

                  Trending

                  Collapse

                  There are no results that meet this criteria.

                  Working...
                  X