Results 1 to 14 of 14

Combine Two Similar Private Subs

Threaded View

swordswinger710 Combine Two Similar Private... 02-27-2012, 09:43 AM
OnErrorGoto0 Re: Combine Two Similar... 02-27-2012, 09:45 AM
swordswinger710 Re: Combine Two Similar... 02-27-2012, 09:51 AM
swordswinger710 Re: Combine Two Similar... 02-27-2012, 10:17 AM
OnErrorGoto0 Re: Combine Two Similar... 02-27-2012, 10:19 AM
swordswinger710 Re: Combine Two Similar... 02-27-2012, 11:25 AM
OnErrorGoto0 Re: Combine Two Similar... 02-27-2012, 11:58 AM
swordswinger710 Re: Combine Two Similar... 02-27-2012, 12:08 PM
swordswinger710 Re: Combine Two Similar... 02-27-2012, 12:13 PM
OnErrorGoto0 Re: Combine Two Similar... 02-27-2012, 12:18 PM
swordswinger710 Re: Combine Two Similar... 02-27-2012, 12:30 PM
OnErrorGoto0 Re: Combine Two Similar... 02-27-2012, 12:40 PM
swordswinger710 Re: Combine Two Similar... 02-27-2012, 01:01 PM
swordswinger710 Re: Combine Two Similar... 02-27-2012, 02:15 PM
  1. #1
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Question Combine Two Similar Private Subs

    Hello,

    I need to add this code from Sheet 2 of my workbook:

    Option Explicit
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
        If Not Intersect(Target, Range("A14,G14,L14,Q14,U14,A16,A18")) Is Nothing Then
            If Target.Value = "P" Then
                 Target.Value = ""
            Else
                 Target.Value = "P"
            End If
        Range("G12").Select  ' or whatever cell you want selected after a click.
        End If
    
    End Sub
    ..to this code on Sheet 1 of the same workbook:

    Option Explicit
    Const tCell As String = "X1" ' Set this to the individual sheet cell
    Private Sub Worksheet_Activate()
        nPages = setPages(Me, tCell)
    End Sub
    Private Sub Worksheet_Calculate()
        nPages = setPages(Me, tCell)
    End Sub
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        With Range("X1")
            If .Value = Empty Then
                Application.EnableEvents = False
                .Select
                MsgBox "Please enter the number of pages required."
                Application.EnableEvents = True
            End If
        End With
    End Sub
    What is the correct way of doing this so that both SelectionChange events will work? I'm trying to learn how.
    Last edited by swordswinger710; 02-27-2012 at 05:30 PM.

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