+ Reply to Thread
Results 1 to 6 of 6

Macro to start automatically when cell in particular column is clicked.

  1. #1
    Registered User
    Join Date
    06-18-2012
    Location
    Perth Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Macro to start automatically when cell in particular column is clicked.

    I do not know how to write VBA code and so far have been creating macros using the Macro Record function.

    I have created a macro (hyperlinktotemplate - which is below) to record data from the current active row and then click on a hyperlink and paste the data into a new workbook.

    Please Login or Register  to view this content.
    What I want to be able to do is get the macro to start automatically when the user clicks in any cell in column D.

    I have googled and found the following code

    Please Login or Register  to view this content.
    I am changing Column G to D and 7 to 4 - and changing Macro3 to Hyperlinktotemplate, but I don't know where or how to add it.

    I have tried pasting the code above my exisitng macro code and also creating a new macro and pasting the detials in but neither is working.

    Sorry in advance if this too basic a question for your forum!

    Thanks

    Jaki
    Last edited by Jaki; 06-19-2012 at 01:47 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    04-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    547

    Re: Macro to start automatically when cell in particular column is clicked.

    This is a worksheet change event macro and it needs to go into the sheet module. Right click the sheet, select View Code and paste the macro into the code windows. The macro that you are calling can stay where it is.

    Oh, and you should edit your post and wrap your code in code tags, so it's easier to read. Select the code and click the # icon.
    Like a post? Click the star below it!

  3. #3
    Registered User
    Join Date
    06-18-2012
    Location
    Perth Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Macro to start automatically when cell in particular column is clicked.

    Thanks so much for your reply.

    I have copied and pasted the Macro (refer below) as per your instructions but there still seems to be an issue with the Macro.

    Please Login or Register  to view this content.
    When I click in Column D the Macro starts to run and then I get a compile error:

    Sub or Function not defined.

    The text "Call Hyperlinktotemplate" is highlighted.

    As I don't know VBA code I don't know how to fix, does Hyperlinktotemplate need to be in inverted commas? - Do you have any suggestions?

    Thanks

    Jaki
    Last edited by Jaki; 06-19-2012 at 01:47 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    04-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    547

    Re: Macro to start automatically when cell in particular column is clicked.

    you are passing an argument with the call to Hyperlinktotemplate, but the sub called Hyperlinktotemplate is not set up to receive a parameter.

    If the Hyperlinktotemplate macro is still the same as in the first post, then just use

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-18-2012
    Location
    Perth Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Macro to start automatically when cell in particular column is clicked.

    I copied and pasted your code above but am getting the same error.
    Please Login or Register  to view this content.
    The error is Sub or Function not defined.

    The text Hyperlinktotemplate is highlighted.

  6. #6
    Registered User
    Join Date
    06-18-2012
    Location
    Perth Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Macro to start automatically when cell in particular column is clicked.

    I managed to get it to work by changing things a bit as per below code:

    Please Login or Register  to view this content.
    Thank you so much for your help - I couldn't have got there without you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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