Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 9 of 9

Thread: VBA : Rename Modules

  1. #1
    Join Date
    19th September 2003
    Posts
    401
    How can you rename the names of the modules in the VB window?

    Ross

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    15th April 2003
    Location
    USA
    Posts
    7,281
    Yes. Just select the module and change its name in the properties window.

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    26th January 2003
    Location
    UK
    Posts
    4,684
    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

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    26th January 2003
    Location
    UK
    Posts
    4,684
    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

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    24th September 2004
    Posts
    12

    Re: VBA : Rename Modules

    Quote 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

    Excel Video Tutorials / Excel Dashboards Reports


  6. #6
    Join Date
    14th July 2004
    Posts
    10,539

    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.

    Excel Video Tutorials / Excel Dashboards Reports


  7. #7
    Join Date
    24th September 2004
    Posts
    12

    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

    Excel Video Tutorials / Excel Dashboards Reports


  8. #8
    Join Date
    6th September 2004
    Posts
    438

    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

  9. #9
    Join Date
    24th September 2004
    Posts
    12

    Re: VBA : Rename Modules

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

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Export All Modules
    By econstantin in forum EXCEL HELP
    Replies: 3
    Last Post: February 11th, 2008, 10:59
  2. Web Queries in Modules
    By Tomski in forum EXCEL HELP
    Replies: 2
    Last Post: August 8th, 2006, 23:05
  3. Replies: 2
    Last Post: September 21st, 2005, 06:25
  4. [Solved] VBA: Rename Modules
    By orion in forum EXCEL HELP
    Replies: 10
    Last Post: June 9th, 2003, 18:16

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
  •  
porno