+ Reply to Thread
Results 1 to 4 of 4

Combining two private subs

  1. #1
    Registered User
    Join Date
    02-27-2013
    Location
    New Orleans, LA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Combining two private subs

    Can someone help me combine these two Private Subs. They are both identical subs entering different values into different ranges. They are both contained in excel sheet1. The top sub enters certain values into a specific range. The bottom sub enters different values into a different range. I need them to both work together. Seperately they work fine. I've tried many different ways to get them to work together; however, I'm just not advanced enough. Thanks in advance.

    --------------------------------------------------------------------------------------------------------------------------
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

    If Target.Count > 1 Or Intersect(Target, Range("D11:O11, D12:O12, D13:O13")) Is Nothing Then Exit Sub
    Select Case Target.Value
    Case Is = ""
    Target.Value = "1"
    Case Is = "1"
    Target.Value = "2"
    Case Is = "2"
    Target.Value = "3"
    Case Is = "3"
    Target.Value = "4"
    Case Is = "4"
    Target.ClearContents
    End Select
    Cancel = True

    End Sub
    -----------------------------------------------------------------------------------------------------------

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

    If Target.Count > 1 Or Intersect(Target, Range("F20:F23, J20:J23, N20:N23")) Is Nothing Then Exit Sub
    Select Case Target.Value
    Case Is = ""
    Target.Value = "85"
    Case Is = "85"
    Target.Value = "170"
    Case Is = "170"
    Target.Value = "255"
    Case Is = "255"
    Target.Value = "340"
    Case Is = "340"
    Target.Value = "425"
    Case Is = "425"
    Target.ClearContents
    End Select
    Cancel = True

    End Sub
    ------------------------------------------------------------------------------

  2. #2
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Combining two private subs

    Hi,

    the easiest way to do would be like this :

    Please Login or Register  to view this content.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  3. #3
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit - Win 11
    Posts
    917

    Re: Combining two private subs

    Or something like this:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-27-2013
    Location
    New Orleans, LA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Combining two private subs

    Wow. Works great. I can't Thank you guys enough. I should have posted sooner and saved myself a lot of time and frustration. Your replies were Greatly apprciated.

+ 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