+ Reply to Thread
Results 1 to 7 of 7

Need help with " Private Sub Worksheet_SelectionChange(ByVal Target As Range) "

  1. #1
    Registered User
    Join Date
    07-02-2016
    Location
    Vernon BC
    MS-Off Ver
    2013
    Posts
    17

    Need help with " Private Sub Worksheet_SelectionChange(ByVal Target As Range) "

    I have this simple code in my sheet and I would like to include 2 cells that are "AJ10" and "AJ13" My skills are limited and I have been searching for a solution but nothing seem to be working



    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Selection.Count = 1 Then
    'change the range to what you want
    If Not Intersect(Target, Range("B25:B54")) Is Nothing Then
    'alternates cells between 1 and 0. If you want to change it to something else then replace the 1 and 0 with your alternatives
    If Selection = 1 Then
    Selection = 0
    Else
    Selection = 1
    End If
    End If
    End If
    End Sub


    Thanks for any help in advance !!
    Last edited by Gerry Pasveer; 08-26-2019 at 10:39 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-02-2012
    Location
    London, England
    MS-Off Ver
    365
    Posts
    397

    Re: Need help with " Private Sub Worksheet_SelectionChange(ByVal Target As Range) "

    There is a straightforward fix for this but first you need to edit your post to wrap the code in code tags as per forum rules.

    Beth.

  3. #3
    Registered User
    Join Date
    07-02-2016
    Location
    Vernon BC
    MS-Off Ver
    2013
    Posts
    17

    Re: Need help with " Private Sub Worksheet_SelectionChange(ByVal Target As Range) "

    Please Login or Register  to view this content.

    hope this works

  4. #4
    Registered User
    Join Date
    07-02-2016
    Location
    Vernon BC
    MS-Off Ver
    2013
    Posts
    17

    Re: Need help with " Private Sub Worksheet_SelectionChange(ByVal Target As Range) "

    Thanks Beth I have reposted

  5. #5
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Need help with " Private Sub Worksheet_SelectionChange(ByVal Target As Range) "

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-02-2016
    Location
    Vernon BC
    MS-Off Ver
    2013
    Posts
    17

    Re: Need help with " Private Sub Worksheet_SelectionChange(ByVal Target As Range) "

    Works perfectly Bob !!! Thank you very much !

  7. #7
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Need help with " Private Sub Worksheet_SelectionChange(ByVal Target As Range) "

    BTW, I know a lot of people probably don't like this construct, and it can cause problems sometimes, but I would use the following in setting the values in my code

    Please Login or Register  to view this content.

+ 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. [SOLVED] Private Sub Worksheet_SelectionChange(ByVal Target As Range) Error
    By JimmyWilliams in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2017, 10:33 PM
  2. Replies: 3
    Last Post: 07-30-2013, 01:38 AM
  3. Replies: 1
    Last Post: 03-06-2012, 01:19 PM
  4. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    By whitesapphire24 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2011, 05:08 AM
  5. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    By dcdusek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-20-2009, 03:04 PM
  6. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    By tawnee jamison in forum Excel General
    Replies: 0
    Last Post: 04-20-2005, 05:13 PM
  7. [SOLVED] Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    By Arturo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-07-2005, 03:06 PM

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