+ Reply to Thread
Results 1 to 4 of 4

Call a specific macro by selecting different cells

  1. #1
    Registered User
    Join Date
    05-06-2013
    Location
    Italy
    MS-Off Ver
    Excel 2007
    Posts
    7

    Call a specific macro by selecting different cells

    Hi, I have a syntax issue to perform a code.
    I have a certain amount of cells (not contiguous).
    I want that when the user changes the value contained in any of those cells, a certain action is performed according to the specific cell selected.
    Now, I've been able to do this with the following code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address(0, 0) = "O7" Then
    ActiveCell.Offset(-1, 0).Select
    Call DEF_NoSTAZ_POS1
    Else
    If Target.Address(0, 0) = "O74" Then
    ActiveCell.Offset(-1, 0).Select
    Call DEF_NoSTAZ_POS2
    Else
    If Target.Address(0, 0) = "F11" Or Target.Address(0, 0) = "N11" Or Target.Address(0, 0) = "V11" Then
    ActiveCell.Offset(0, 0).Select
    Call SUCC_AUTO
    End If
    End If
    End If
    End Sub

    I guess there is a better syntax for this. I tried to use the "Case select" syntax, but I don't know how to in this particular case.
    Especially, for the last call of the code above, it is annoying because the cells I have to assign to the "SUCC_AUTO" macro are more than the ones presented (F11, N11, V11 and other 150 cells on the same columns but on other rows).
    Any idea to help?

    Thanks in advance.
    Raf

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2010
    Posts
    2,308

    Re: Call a specific macro by selecting different cells

    Give this a try....it's just a snippet

    Please Login or Register  to view this content.
    HTH
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  3. #3
    Registered User
    Join Date
    05-06-2013
    Location
    Italy
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Call a specific macro by selecting different cells

    It does work. Weird.
    I tried the same thing yesterday and it didn't.
    I probably did another mistake in the attempt and I couldn't see it.
    Or it's just another Microsoft mystery...

    Thanks for the quick support Ernest

  4. #4
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2010
    Posts
    2,308

    Re: Call a specific macro by selecting different cells

    I like the Microsoft Mystery Theory.....glad I could 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