+ Reply to Thread
Results 1 to 18 of 18

Sheet Change Event Dubuggin: Restrict Cell Values toand Changing cells based on input

Hybrid View

cmore Sheet Change Event Dubuggin:... 10-22-2013, 09:12 AM
JosephP Re: Sheet Change Event... 10-22-2013, 10:30 AM
cmore Re: Sheet Change Event... 10-22-2013, 03:33 PM
cmore Re: Sheet Change Event... 10-23-2013, 09:58 PM
cmore Re: Sheet Change Event... 10-24-2013, 12:03 AM
JosephP Re: Sheet Change Event... 10-24-2013, 03:30 AM
cmore Re: Sheet Change Event... 10-24-2013, 08:17 AM
JosephP Re: Sheet Change Event... 10-24-2013, 08:26 AM
cmore Re: Sheet Change Event... 10-24-2013, 08:37 AM
JosephP Re: Sheet Change Event... 10-24-2013, 09:01 AM
cmore Re: Sheet Change Event... 10-24-2013, 05:20 PM
cmore Re: Sheet Change Event... 10-24-2013, 05:35 PM
cmore Re: Sheet Change Event... 10-24-2013, 06:33 PM
cmore Re: Sheet Change Event... 10-24-2013, 09:33 PM
JosephP Re: Sheet Change Event... 10-25-2013, 06:37 AM
cmore Re: Sheet Change Event... 10-25-2013, 09:21 PM
JosephP Re: Sheet Change Event... 10-28-2013, 06:08 AM
cmore Re: Sheet Change Event... 10-28-2013, 02:37 PM
  1. #1
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Sheet Change Event Dubuggin: Restrict Cell Values toand Changing cells based on input

    first remove the
    application.enableevents = true
    line from your Build sub or you may end up stuck in a loop you can't terminate

    second your code only monitors one cell-column C and the row (teststaken + 7) which you update as soon as an entry is made in a row. so once you've made an entry you are only monitoring the cell below it. I don't really know why you set it up that way so can't advise what your best solution is-it may be just to monitor the whole column C
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  2. #2
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Sheet Change Event Dubuggin: Restrict Cell Values toand Changing cells based on input

    Quick question, why take off app.enabevent = true? Don't I have to cut it back on after I cut it off?

    So I did that to ignore changes above the header. changed code to If
    Target.Column = 3 And Target.Row > Distance Then
    Worked perfectly for updating.

    How would you do for delete on update
    Last edited by cmore; 10-24-2013 at 05:25 PM.

  3. #3
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Sheet Change Event Dubuggin: Restrict Cell Values toand Changing cells based on input

    So I got the lovely infinite loop........searching for solution

  4. #4
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Sheet Change Event Dubuggin: Restrict Cell Values toand Changing cells based on input

    Possible Solution?

    Private Sub Worksheet_Change(ByVal Target As Range)
        
     Application.EnableEvents = False
        Build
        
    If Target.Column = 3 And Target.Row > Distance Then
            item = Cells(Target.Row, 3)
            If item = vbNullString Then
                Cells(Target.Row, 1).Resize(1, 67).Clear
                Exit Sub
            End If
            If IsError(Application.Match(item, PTests, 0)) Then
                MsgBox "Please Insert Valid PTest"
                Cells(Target.Row, 3) = vbNullString
            Else: x = WorksheetFunction.Match(item, PTests, 0)
    
            Cells(Target.Row, 2) = Date + Time
            Cells(Target.Row, 1) = Target.Row - 6
            Cells(Target.Row, 3).Font.Color = 16711680
            Cells(Target.Row, 1).Resize(1, 2).HorizontalAlignment = xlCenter
            Cells(Target.Row, 6) = PTestsAdmin(x)
            End If
        End If
    
        TestsTaken = Sheet3.Cells(Distance, 1).End(xlDown)
        Build
    
    Application.EnableEvents = True
    
    End Sub
    Last edited by cmore; 10-24-2013 at 07:46 PM.

  5. #5
    Forum Contributor
    Join Date
    07-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    476

    Re: Sheet Change Event Dubuggin: Restrict Cell Values toand Changing cells based on input

    Updated, is there a better way?

    Private Sub Worksheet_Change(ByVal Target As Range)
        
    Application.EnableEvents = False
        
    If Target.Column = 3 And Target.Row > Distance Then
            item = Cells(Target.Row, 3)
            If item = vbNullString Then
                Cells(Target.Row, 1).Resize(1, 67).Clear
                Application.EnableEvents = True
                Exit Sub
            End If
            
            If IsEmpty(PTests) Then
                Build
            End If
            
            If IsError(Application.Match(item, PTests, 0)) Then
                MsgBox "Please Insert Valid PTest"
                Cells(Target.Row, 3) = vbNullString
            Else: x = Application.Match(item, PTests, 0)
    
            Cells(Target.Row, 2) = Date + Time
            Cells(Target.Row, 1) = Target.Row - 6
            Cells(Target.Row, 3).Font.Color = 16711680
            Cells(Target.Row, 1).Resize(1, 2).HorizontalAlignment = xlCenter
            Cells(Target.Row, 6) = PTestsAdmin(x)
            End If
        
    Else
    Application.EnableEvents = True
    Exit Sub
    End If

+ 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. [SOLVED] Restrict Cells depending on input in another cell
    By Dave350z in forum Excel General
    Replies: 2
    Last Post: 01-28-2013, 11:38 AM
  2. Macro to replace cells value automatically based on another cell change event
    By phsilverhp in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-09-2011, 04:36 AM
  3. Replies: 1
    Last Post: 05-05-2010, 04:18 AM
  4. Change Event based on two other cell values
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-10-2007, 05:15 PM
  5. New to excel, having trouble changing values based on an input cell
    By MyUserName in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-18-2006, 10:20 PM

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