+ Reply to Thread
Results 1 to 7 of 7

Modify code at runtime

  1. #1
    Registered User
    Join Date
    05-30-2012
    Location
    California, USA
    MS-Off Ver
    Office 365
    Posts
    26

    Modify code at runtime

    At runtime a combobox userform is created with the necessary code. Also at runtime several worksheet codemodules are generated. All of this works fine. Also at runtime a dynamic named range is created based on user input of a job number. This range is used in setting the row source for the userform combobox. I have a line of code that needs to have this range as the row source, instead of the dummy one that was used. I am able to print the line I want to change in the immediate window but can not figure out how to change it. I am not overly familiar with the code module properties but I would like to know how to replace this line of code, any assistance would be greatly appreciated. I am using Excel 2010 with Windows 7.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Modify code at runtime

    Hi, chipnputt,

    but I would like to know how to replace this line of code
    Wouldn´t it be helpful to post the code line in question or how it is inserted?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    05-30-2012
    Location
    California, USA
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Modify code at runtime

    Thank you for your reply but I have solved the problem.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Modify code at runtime

    Hi, chipnputt,

    glad you got it solved by yourself but you might consider to give other user finding this thread a hint on how you solved the modification.

    Ciao,
    Holger

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    What exactly do you need to replace?
    If posting code please use code tags, see here.

  6. #6
    Registered User
    Join Date
    05-30-2012
    Location
    California, USA
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Modify code at runtime

    The way I solved the problem was to add the code module once the user input was received. Initially, I added the code module for several sheets as the workbook was opened, I removed the part that depended on the sheet using the user input and added it after the input was received.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Modify code at runtime

    Are you sure using code to write code is the only solution?

    For example, you could use workbook level events instead of having code in individual worksheets.

    Or you could have a template worksheet which contains the code and instead if adding new, blank sheets copy the template sheet.

    As fir the combobox, why not populate it when it's created.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to modify VB code?
    By sem in forum Excel General
    Replies: 3
    Last Post: 08-07-2012, 05:29 AM
  2. [SOLVED] Modify a code
    By Samsungg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2012, 09:14 PM
  3. [SOLVED] Array Formula vs vBa code - How To Modify My Messy Code To One Of Those
    By ScotyB in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-20-2012, 12:04 AM
  4. I want to modify the code
    By hesham63 in forum Excel General
    Replies: 8
    Last Post: 07-30-2011, 10:36 AM
  5. Help me modify this VBA code please:
    By sanmisds1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-15-2005, 11:48 PM

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