+ Reply to Thread
Results 1 to 4 of 4

Combine two codes

Hybrid View

  1. #1
    Registered User
    Join Date
    10-27-2014
    Location
    Melbourne, Australia
    MS-Off Ver
    365
    Posts
    18

    Combine two codes

    Hi there,

    Can somebody combine the following codes for me, please??

    I am getting "Ambiguous name detected:Worksheet_BeforeDoubleclick" error


    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        If Not Intersect(Target, Range("D10:E110,G10:G110")) Is Nothing Then
            Application.EnableEvents = False
            If ActiveCell.Value = ChrW(&H2713) Then
                ActiveCell.ClearContents
            Else
                ActiveCell.Value = ChrW(&H2713)
            End If
            Cancel = True
        End If
        Application.EnableEvents = True
    End Sub
    --------------------
    
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        If Target.Column = 7 And (Target.Row >= 9 And Target.Row <= 110) Then
    
        Application.ScreenUpdating = False
        
        Sheet = ActiveCell.Offset(0, -1).Value
        
        If Worksheets(Sheet).Visible = False Then
            Worksheets(Sheet).Visible = True
            ActiveCell.Value = "ChrW(&H2713)"
        Else
            Worksheets(Sheet).Visible = False
            ActiveCell.Value = ""
        End If
        
        Application.ScreenUpdating = True
    
    End If
    Cancel = True
    
    End Sub
    Thanks

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Combine two codes

    Hello
    May be
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        If Not Intersect(Target, Range("D10:E110,G10:G110")) Is Nothing Then
            Application.EnableEvents = False
                If ActiveCell.Value = ChrW(&H2713) Then
                    ActiveCell.ClearContents
                Else
                    ActiveCell.Value = ChrW(&H2713)
                End If
                Cancel = True
            Application.EnableEvents = True
        End If
        
        If Target.Column = 7 And (Target.Row >= 9 And Target.Row <= 110) Then
            Application.ScreenUpdating = False
                Dim sheet As String
                sheet = ActiveCell.Offset(0, -1).Value
        
                If Worksheets(sheet).Visible = False Then
                    Worksheets(sheet).Visible = True
                    ActiveCell.Value = "ChrW(&H2713)"
                Else
                    Worksheets(sheet).Visible = False
                    ActiveCell.Value = ""
                End If
            Application.ScreenUpdating = True
            Cancel = True
        End If
    End Sub
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Registered User
    Join Date
    10-27-2014
    Location
    Melbourne, Australia
    MS-Off Ver
    365
    Posts
    18

    Re: Combine two codes

    Thanks Heaps!!!!

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Combine two codes

    You're welcome. Glad I can offer some help
    Please mark the thread as solved

+ 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. How do I combine these 2 codes?
    By X myth in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2017, 01:07 AM
  2. [SOLVED] combine two VBA codes into one
    By PsychicFish in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2016, 05:37 AM
  3. Need to combine codes
    By abelle82 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-11-2015, 04:33 PM
  4. Combine 2 VBA codes in one
    By Adile in forum Excel General
    Replies: 3
    Last Post: 05-12-2015, 03:29 AM
  5. Combine 2 codes
    By Minhaz.iubat in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-06-2014, 05:46 AM
  6. [SOLVED] How to combine these two set's of codes?
    By aadeshgandhi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-22-2013, 07:26 PM
  7. Combine vba codes
    By mmwltd in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-22-2010, 08:32 AM

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