+ Reply to Thread
Results 1 to 4 of 4

Two VBA changes not allowed??

Hybrid View

playtowinpb@msn.com Two VBA changes not allowed?? 08-09-2012, 12:55 PM
shg Re: Two VBA changes not... 08-09-2012, 01:11 PM
playtowinpb@msn.com Re: Two VBA changes not... 08-09-2012, 01:27 PM
arlu1201 Re: Two VBA changes not... 08-09-2012, 02:51 PM
  1. #1
    Registered User
    Join Date
    02-17-2010
    Location
    new york
    MS-Off Ver
    Excel 2007
    Posts
    46

    Two VBA changes not allowed??

    Hello,

    From the research I've done the VBA code won't allow these two CHANGES to happen and need to be combined. I keep getting "Ambiguous name detected: Worksheet_Change". I am a VBA noob and need assistance. Need the two codes below combined. Thank you all.

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("A5:A3000")) Is Nothing Then
    With Target(1, 3)
    .Value = Date
    .EntireColumn.AutoFit
    End With
    End If
    End Sub

    AND


    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Target.Column = 7 Then Exit Sub
    Application.ScreenUpdating = False
    Select Case Target.Value
    Case "Hold"
    Application.EnableEvents = False
    Cells(Target.Row, 8).Value = Now
    Cells(Target.Row, 8).NumberFormat = "MM/DD/YY"
    Cells(Target.Row, 9).Value = ""
    Application.EnableEvents = True
    Case "Off Hold"
    Application.EnableEvents = False
    Cells(Target.Row, 9).Value = Now
    Cells(Target.Row, 9).NumberFormat = "MM/DD/YY"
    Cells(Target.Row, 8).Value = ""
    Application.EnableEvents = True
    End Select
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Two VBA changes not allowed??

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Cells.Count > 1 Then Exit Sub
    
        On Error GoTo Oops
        Application.EnableEvents = False
    
        If Not Intersect(Target, Range("A5:A3000")) Is Nothing Then
            Cells(Target.Row, "C").Value = Date
            Columns("C").AutoFit
        End If
    
        If Target.Column = 7 Then
            Select Case Target.Value
                Case "Hold"
                    Cells(Target.Row, "H").Value = Now
                    Cells(Target.Row, "H").NumberFormat = "MM/DD/YY"
                    Cells(Target.Row, "I").ClearContents
                Case "Off Hold"
                    Cells(Target.Row, "I").Value = Now
                    Cells(Target.Row, "I").NumberFormat = "MM/DD/YY"
                    Cells(Target.Row, "H").ClearContents
            End Select
        End If
    
    Oops:
        Application.EnableEvents = True
    End Sub
    Please use CODE tags.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    02-17-2010
    Location
    new york
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Two VBA changes not allowed??

    Perfect!!!! Thank you for your help! You are a Guru.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Two VBA changes not allowed??

    playtowinpb@msn.com,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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