+ Reply to Thread
Results 1 to 3 of 3

Execute on Cell Change - Problem

Hybrid View

  1. #1
    Marty
    Guest

    Execute on Cell Change - Problem

    Hello, folks:

    I'm trying to execute a series of code steps based on changes to ranges of
    cells. I have used this code before, but for some reason it's not working
    now and I can't spot why.

    Basically, I want to change the value of cells in a column AB (28) of my
    worksheet if any cell in ranges D8:F1000 or V8:X1000 change.

    Here is the code. Can anyone spot anything obvious?

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Dim myRow&, myCol&
    myRow = Target.Row
    myCol = Target.Column
    If myRow > 7 And myRow < 1001 Then
    If (myCol > 6 And MyCOL < 9) Or _
    (myCol > 21 And MyCOL < 25) Then

    {code steps here, which do a row-by-row evaluation of the contents of the
    target ranges and put a string of text (which varies depending upon the
    contents of the targets) in the corresponding row in column 28.}

    End If 'myCol
    End If 'myRow

    I commented out the code above and tried it with a command button and it
    works fine, so I know the code steps are not the problem.

    Thoughts? Thanks in advance.

    MARTY

  2. #2
    Tom Ogilvy
    Guest

    Re: Execute on Cell Change - Problem

    ? Range("D1").Column
    4
    ? Range("F1").Column
    6

    so
    > If (myCol > 6 And MyCOL < 9) Or _


    should be
    If (myCol > 3 And MyCOL < 7) Or _


    --
    Regards,
    Tom Ogilvy

    "Marty" <Marty@discussions.microsoft.com> wrote in message
    news:C48FAC19-8B8A-40EA-B446-AC4D14BCF346@microsoft.com...
    > Hello, folks:
    >
    > I'm trying to execute a series of code steps based on changes to ranges of
    > cells. I have used this code before, but for some reason it's not working
    > now and I can't spot why.
    >
    > Basically, I want to change the value of cells in a column AB (28) of my
    > worksheet if any cell in ranges D8:F1000 or V8:X1000 change.
    >
    > Here is the code. Can anyone spot anything obvious?
    >
    > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > Dim myRow&, myCol&
    > myRow = Target.Row
    > myCol = Target.Column
    > If myRow > 7 And myRow < 1001 Then
    > If (myCol > 6 And MyCOL < 9) Or _
    > (myCol > 21 And MyCOL < 25) Then
    >
    > {code steps here, which do a row-by-row evaluation of the contents of the
    > target ranges and put a string of text (which varies depending upon the
    > contents of the targets) in the corresponding row in column 28.}
    >
    > End If 'myCol
    > End If 'myRow
    >
    > I commented out the code above and tried it with a command button and it
    > works fine, so I know the code steps are not the problem.
    >
    > Thoughts? Thanks in advance.
    >
    > MARTY




  3. #3
    Marty
    Guest

    Re: Execute on Cell Change - Problem

    That did it. Thanks so much, Tom. I figued it was something simple I was
    overlooking.

    {Note to self: D = 4, D<>6 . . .}

    "Tom Ogilvy" wrote:

    > ? Range("D1").Column
    > 4
    > ? Range("F1").Column
    > 6
    >
    > so
    > > If (myCol > 6 And MyCOL < 9) Or _

    >
    > should be
    > If (myCol > 3 And MyCOL < 7) Or _
    >
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Marty" <Marty@discussions.microsoft.com> wrote in message
    > news:C48FAC19-8B8A-40EA-B446-AC4D14BCF346@microsoft.com...
    > > Hello, folks:
    > >
    > > I'm trying to execute a series of code steps based on changes to ranges of
    > > cells. I have used this code before, but for some reason it's not working
    > > now and I can't spot why.
    > >
    > > Basically, I want to change the value of cells in a column AB (28) of my
    > > worksheet if any cell in ranges D8:F1000 or V8:X1000 change.
    > >
    > > Here is the code. Can anyone spot anything obvious?
    > >
    > > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > > Dim myRow&, myCol&
    > > myRow = Target.Row
    > > myCol = Target.Column
    > > If myRow > 7 And myRow < 1001 Then
    > > If (myCol > 6 And MyCOL < 9) Or _
    > > (myCol > 21 And MyCOL < 25) Then
    > >
    > > {code steps here, which do a row-by-row evaluation of the contents of the
    > > target ranges and put a string of text (which varies depending upon the
    > > contents of the targets) in the corresponding row in column 28.}
    > >
    > > End If 'myCol
    > > End If 'myRow
    > >
    > > I commented out the code above and tried it with a command button and it
    > > works fine, so I know the code steps are not the problem.
    > >
    > > Thoughts? Thanks in advance.
    > >
    > > MARTY

    >
    >
    >


+ 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