Results 1 to 2 of 2
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    starrt macro when digit 7 character (2000)

    have a sheet similar a data entry.
    The user can insert in column I or in column J a code with 7 character.
    Now i want to scart MY_Macro when the last digit is the last 7th carachter of string, how to?

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: starrt macro when digit 7 character (2000)

    I don't completely understand when you want the code to run. If you want the macro to run whenever the value in I matches the last value of the string in col J then you can add the code to the worksheet object:

    <pre>Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rCell As Range
    Dim sI As String
    Dim sJ As String
    For Each rCell In Target
    With rCell
    If .Column = 9 Or .Column = 10 Then
    sI = Cells(.Row, 9)
    sJ = Right(Cells(.Row, 10), 1)
    If sI = sJ Then
    MY_Macro
    End If
    End If
    End With
    Next
    Set rCell = Nothing
    End Sub</pre>


    Note: if more than 1 cell is changed, the macro could be run multiple times...

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •