+ Reply to Thread
Results 1 to 7 of 7

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

Hybrid View

  1. #1
    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) "

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        On Error GoTo wsc_exit
        
        Application.EnableEvents = False
        
        If Target.Cells.Count = 1 Then
        
            'change the range to what you want
            If Not Intersect(Target, Range("B25:B54, AJ10, AJ13")) 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 Target.Value = 1 Then
                
                    Target.Value = 0
                Else
                
                    Target.Value = 1
                End If
            End If
        End If
    
    wsc_exit:
        Application.EnableEvents = True
    End Sub

  2. #2
    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 !

+ 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