+ Reply to Thread
Results 1 to 3 of 3

how to set a macro that only works when the active cell is on a certain column?

  1. #1
    Forum Contributor
    Join Date
    12-03-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    107

    how to set a macro that only works when the active cell is on a certain column?

    Hi guys this is my example:

    A user will put an item code on column B and after he/she puts the code he/she then clicks the cell where the code was put, then he will press the shortcut for the macro to run and the macro will do a vlookup on the active cell and fill up the rest of the row with the necessary data. everything is fine except when the user accidentally presses the shortcut for the macro on another column that is not column b the macro will still run and mess up the sheet. So what i'd want is a macro to put at the beggining of my original macro that when the active cell is not on column b, the macro will return an error saying "you must be in column B to perform this macro". Here is my code:

    Please Login or Register  to view this content.
    The code above's intention is that the activecell must be on column B so the necessary cells next to it will be filled correctly.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: how to set a macro that only works when the active cell is on a certain column?

    Try this. I cleaned up the other code as well.

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 02-11-2013 at 01:13 AM.

  3. #3
    Forum Contributor
    Join Date
    12-03-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    107

    Re: how to set a macro that only works when the active cell is on a certain column?

    Exactly what i was looking for. Thank you and i appreciate the cleaning up of the code as well!

+ 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