+ Reply to Thread
Results 1 to 10 of 10

Automatic Change in Code

  1. #1
    Registered User
    Join Date
    06-13-2007
    Posts
    58

    Red face Automatic Change in Code

    Is there any way, in which i can make my code dynamic?? For example, in a code written in VBA, there is a reference to particular sheet, say "ABC". If i change the name from "ABC" to "ABCD" from excel, the underlying code should change automatically from "ABC" to "ABCD".

    I want to make my code dynamic..

    I hope u get my problem... can any1 help me on this??
    Last edited by crapmind; 06-16-2007 at 04:04 PM.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Say the sheet tab is always say sheet 3 then use the number

    e.g

    Please Login or Register  to view this content.
    HTH

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    06-13-2007
    Posts
    58
    where to paste the code??

  4. #4
    Registered User
    Join Date
    06-13-2007
    Posts
    58
    even after pasting the code... its showing an error "Subscript out of range" whenever i change the name and re-run the macro

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    What sheet number is your sheet ??


    VBA Noob

  6. #6
    Registered User
    Join Date
    06-13-2007
    Posts
    58
    c the code

    Please Login or Register  to view this content.

    #

    This code is written in "ThisWorkbook"

    There are another 30 sheets "060107" series... like "060207", "060307" etc.

    Now if i change the name of the sheet "PLA" from Excel then the macro does not run. same as with other sheet.

    Is there any way in which i can make things dynamic.. so that even some user changes the name from excel itself, the code should adjust automatically and macro should run as before.
    Last edited by VBA Noob; 06-17-2007 at 11:40 AM.

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Create a named range consisiting of one cell on PLA. Lets call it "Base"
    Modify your code, replacing
    Please Login or Register  to view this content.
    , with
    Please Login or Register  to view this content.
    If the user changes the name of PLA, the name will automaticaly adjust and your code won't get lost.
    Last edited by mikerickson; 06-17-2007 at 03:10 AM.

  8. #8
    Registered User
    Join Date
    06-13-2007
    Posts
    58
    Thanks a lot dude

    ur solution solved my problem

  9. #9
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Please read forum rules below and wrap the code

    VBA Noob

  10. #10
    Registered User
    Join Date
    06-13-2007
    Posts
    58
    Sorry man,

    new to this forum.. was not aware of the rule... will take care of the same from the next time.

+ 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