+ Reply to Thread
Results 1 to 4 of 4

macro to execute code from cell.value?

  1. #1
    Forum Contributor wamp's Avatar
    Join Date
    11-10-2008
    Location
    Norway
    MS-Off Ver
    97, 2000 & 2003 (diff. workstations)
    Posts
    184

    macro to execute code from cell.value?

    Hi.
    I'm trying to create a dynamic custom menu in excel where people can specify their own buttons; eg. the button-names and what they do.

    In that scenario, I was wondering if it is possible for a macro-script to call/execute code directly from a cell?

    Say for instance that cell A1 in sheet1 has the value:
    Please Login or Register  to view this content.
    and in a module I have something similar to
    Please Login or Register  to view this content.

    ...
    If this is not possible; is it then possible to make a macro that adds a whole new sub-routine? (create codebehind from codebehind sort of speak)
    for instance a macro that when run checks if a named sub-routine exists, and then creates a new sub where sub-name = cell-value, code to run = another-cell.value etc?

    not easy to try typing code you don't know what is, but I would assume something like:
    Please Login or Register  to view this content.
    Last edited by wamp; 04-19-2010 at 04:24 AM. Reason: got a link to the question at hand

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: macro to execute code from cell.value?

    Perhaps the below link will be of interest

    http://www.cpearson.com/excel/vbe.aspx

  3. #3
    Forum Contributor wamp's Avatar
    Join Date
    11-10-2008
    Location
    Norway
    MS-Off Ver
    97, 2000 & 2003 (diff. workstations)
    Posts
    184

    Re: macro to execute code from cell.value?

    ahh.. just what I was looking for :-D

    thanks for the link

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: macro to execute code from cell.value?

    Here would be a quick example:

    Please Login or Register  to view this content.
    wherein code module is added, executed and then removed.

    (requires MS VBA Extensibility Library referenced)

    You should find you can incorporate in line with a change event if needed.

    I'm not really sure how practical this type of thing is though - the more knowledgeable folk around here might have some caveats to add.

+ 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