+ Reply to Thread
Results 1 to 7 of 7

Exit sub if even row selected in specific column

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Exit sub if even row selected in specific column

    Hi.
    The macro code below will exit if the user selects any column other than column A.
    Can anyone add to the code that if the user selects an even row in column A that the code will exit as well?

    Thank you.

    If ActiveCell.Column <> 1 Then Exit Sub

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Exit sub if even row selected in specific column

    If ActiveCell.Column <> 1 Then
        Exit Sub
    ElseIf Activecell.column = 1 and Application.IsEven(ActiveCell.Row) Then
        Exit Sub
    End If
    Last edited by Solus Rankin; 04-03-2014 at 01:30 PM.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Exit sub if even row selected in specific column

    thank you but the code didn't exit whether I landed on an even row or odd row

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Exit sub if even row selected in specific column

    Hi, kosherboy,

    With ActiveCell
      If .Column = 1 Then
        If (.Row Mod 2 = 0) Then Exit Sub
      Else
        Exit Sub
      End If
    End With
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Exit sub if even row selected in specific column

    HaHoBe, thank you! It worked!

    Best of luck.

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Exit sub if even row selected in specific column

    Hi, kosherboy,

    With ActiveCell
      If .Column = 1 And (.Row Mod 2 = 0) Then Exit Sub
    End With
    Ciao,
    Holger

  7. #7
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Exit sub if even row selected in specific column

    Quote Originally Posted by HaHoBe View Post
    Hi, kosherboy,

    With ActiveCell
      If .Column = 1 And (.Row Mod 2 = 0) Then Exit Sub
    End With
    Ciao,
    Holger
    thanks hahobe the code works when I'm on column A but when I am on column B the code doesn't work or better yet the code doesn't exit sub.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. When Cancel is selected, I want to exit sub
    By Rubert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-20-2014, 05:02 PM
  2. [SOLVED] Macro to move any selected cell to a specific column on the same row
    By Jonah Mulski in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-30-2013, 12:23 PM
  3. Insert Date When Cell in specific column is selected
    By G33kman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-13-2013, 08:19 PM
  4. Auto save on exit selected data sheets, instead of whole project?
    By Bafa in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-09-2008, 01:38 PM
  5. Move to a specific cell on exit of current
    By jafo1 in forum Excel General
    Replies: 3
    Last Post: 06-24-2005, 04:29 PM

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