+ Reply to Thread
Results 1 to 44 of 44

Target.Address syntax

  1. #1
    Registered User
    Join Date
    08-22-2005
    Posts
    20

    Target.Address syntax

    Can someone tell me how to correct my syntax in the following code? Right now it does nothing. Thanks!!


    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long

    l_LastRow = Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Row

    For x = 3 To (l_LastRow - 1) Step 1
    If Target.Address = Cells(x, 4) Then
    Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    End If
    Next x

    End Sub

  2. #2
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  3. #3
    Registered User
    Join Date
    07-03-2004
    Posts
    49
    Dear Coolboy

    For x = 3 To (l_LastRow - 1) Step 1
    If Target.Address = Cells(x, 4) Then
    Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    End If
    Next x


    In your above code, for starters,

    Target.Address will return the absolute (by default) address of the Target cell. From memory, the argument 'external' by default is False giving you the cell address.

    The 'Cells(x,4)' will return the value in the Cell(x,4). More than likely these 2 values will always be different making the if condition False. With you not having the Else clause, it doesn't do anything!

    Hope this helps!


    Best regards


    Deepak Agarwal

  4. #4
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  5. #5
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  6. #6
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  7. #7
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  8. #8
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  9. #9
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  10. #10
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  11. #11
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  12. #12
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  13. #13
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  14. #14
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  15. #15
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  16. #16
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  17. #17
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  18. #18
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  19. #19
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  20. #20
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  21. #21
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  22. #22
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  23. #23
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  24. #24
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  25. #25
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  26. #26
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  27. #27
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  28. #28
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  29. #29
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  30. #30
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  31. #31
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  32. #32
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  33. #33
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  34. #34
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  35. #35
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  36. #36
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  37. #37
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  38. #38
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  39. #39
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  40. #40
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  41. #41
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  42. #42
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

  43. #43
    Trevor Shuttleworth
    Guest

    Re: Target.Address syntax

    Maybe:

    If Target.Address = Cells(x, 4).Address Then

    Regards

    Trevor


    "Coolboy55" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile:
    > http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926
    >




  44. #44
    Dave Peterson
    Guest

    Re: Target.Address syntax

    One more way:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim l_LastRow As Long
    Dim myRng As Range

    If Target.Cells.Count > 1 Then Exit Sub

    l_LastRow = Me.Cells.Find(What:="*", lookat:=xlWhole, _
    LookIn:=xlFormulas, After:=Me.Range("a1"), _
    SearchDirection:=xlPrevious).Row

    Set myRng = Me.Range("D3", Me.Cells(l_LastRow, "D"))

    On Error GoTo errHandler:

    With Target
    If Intersect(.Cells, myRng) Is Nothing Then
    Exit Sub
    End If

    If IsNumeric(.Offset(0, 1).Value) _
    And IsNumeric(.Value) Then
    Application.EnableEvents = False
    .Offset(0, 1).Value = Target.Offset(0, 1).Value * Target.Value
    End If
    End With

    errHandler:
    Application.EnableEvents = True

    End Sub



    Coolboy55 wrote:
    >
    > Can someone tell me how to correct my syntax in the following code?
    > Right now it does nothing. Thanks!!
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > Dim l_LastRow As Long
    >
    > l_LastRow = Cells.Find(What:="*", After:=[A1],
    > SearchDirection:=xlPrevious).Row
    >
    > For x = 3 To (l_LastRow - 1) Step 1
    > If Target.Address = Cells(x, 4) Then
    > Cells(x, 5).Value = Cells(x, 5).Value * Cells(x, 4).Value
    > End If
    > Next x
    >
    > End Sub
    >
    > --
    > Coolboy55
    > ------------------------------------------------------------------------
    > Coolboy55's Profile: http://www.excelforum.com/member.php...o&userid=26508
    > View this thread: http://www.excelforum.com/showthread...hreadid=397926


    --

    Dave Peterson

+ 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