Results 1 to 5 of 5

A Macro Error

Threaded View

  1. #1
    Registered User
    Join Date
    09-21-2015
    Location
    İstanbul, Turkey
    MS-Off Ver
    2010
    Posts
    2

    A Macro Error

    Hi,

    First of all, I have no knowledge of macros or VBAs, I only try to find some useful macros on the net to use when necessary. I have found two such macros recenly, and they work well separately, but not on the same macro page. I keep getting "Compile Error: Ambiguous name detected: Worksheet_Change" I tried to figure it out on my own and it seems to be about two macros having the same name or something.
    Private Sub Worksheet_Change(ByVal Target As Range)

    If Range("'D13") = "New" Then
            Rows("7").EntireRow.Hidden = True
        Else
            Rows("7").EntireRow.Hidden = False
        End If
    
    End Sub
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim oneCell As Range
        On Error GoTo ErrorOut
        For Each oneCell In ActiveSheet.Cells.SpecialCells(xlCellTypeAllValidation)
            If Not oneCell.Validation.Value Then oneCell.ClearContents
        Next oneCell
    ErrorOut:
    Application.EnableEvents = True
    On Error GoTo 0
    End Sub

    So, I tried to delete the second name, it stopped giving the error, but the first macro with if function stopped working.

    Private Sub Worksheet_Change(ByVal Target As Range)
    
        If Range("'D13") = "New" Then
            Rows("7").EntireRow.Hidden = True
        Else
            Rows("7").EntireRow.Hidden = False
        End If
    
        Dim oneCell As Range
        On Error GoTo ErrorOut
        For Each oneCell In ActiveSheet.Cells.SpecialCells(xlCellTypeAllValidation)
            If Not oneCell.Validation.Value Then oneCell.ClearContents
        Next oneCell
    ErrorOut:
    Application.EnableEvents = True
    On Error GoTo 0
    End Sub
    I want them both to work at the same time, could anybody help? Thanks in advanced.
    Last edited by gme; 09-21-2015 at 05:50 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Sort Macro Run-time error '1004': Application/Object-defined error.
    By sam1212 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-22-2014, 10:05 AM
  2. MACRO ERROR WITH EXCEL 2013 - Run-Time Error '-2147417848 (80010108)'
    By graiggoriz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2014, 11:07 AM
  3. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  4. [SOLVED] Simple Calendar pop up macro --> error Run-time error '424': Object required
    By am_hawk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2013, 10:38 AM
  5. Print Macro / module error & Update / Clear Macro error
    By mal.b.graham in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-28-2012, 06:40 PM
  6. [SOLVED] Macro error - Run time error 1004 (App defined/Object Defined error)
    By jlax34 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-06-2012, 03:02 PM
  7. Excel Macro Error - Run time error 1004 - Paste method of worksheet class failed
    By kvflynn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2012, 10:51 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