+ Reply to Thread
Results 1 to 7 of 7

Macro starts on clicking only certain column cells

  1. #1
    Registered User
    Join Date
    03-04-2008
    Posts
    27

    Macro starts on clicking only certain column cells

    Hi all,

    I have it set up on a sheet for a macro to start whenever a cell is clicked, but I'm trying to figure out how to narrow that down to only certain column cells being clicked.

    You can see the current code below... and it just basically activates the AddToCell macro once any cell is clicked. The problem with this is, it errors on cells with text in them and no longer lets me edit the sheet without disabling the macros and so on. So, instead of it activating on all cells, I'd like to find a way to have it just work for columns E-I.

    Any help would be appreciated.

    Thanks much

    Please Login or Register  to view this content.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Firstly you need to move the macro to a Standard Module. Then add this code to your worksheet event, it will limit the action to the specified Columns & only empty cells
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    03-04-2008
    Posts
    27
    I'm an extreme novice when it comes to messing with VBA... can you explain to me a little more in depth how to do this with the module and everything?

    Thanks for your help

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Insert a Module in the VBA from yhe VB EDitor Insert menu. Cut the AddtoCell macro & paste it into the new module. Then overwrite the existing code in the sheet module with the new.
    Please Login or Register  to view this content.
    Last edited by royUK; 03-07-2008 at 04:13 AM.

  5. #5
    Registered User
    Join Date
    03-04-2008
    Posts
    27
    OK.. almost there.. the only issue I've run into now is that the macro doesn't seem to work on pre-existing figures. The idea is that there is a number already in the cell and I can click it, type in a number and it will add to the previous one. It works on blank cells, but the ones that have something in them currently don't seem to run the macro.

    Thanks for your help

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    In the notes I suggested that you might want to remove this line

    Please Login or Register  to view this content.
    Like this:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-04-2008
    Posts
    27
    Oops... sorry about that... it works perfect now, thanks very much for your help

+ 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