Results 1 to 1 of 1

Record change only if it is text

Threaded View

  1. #1
    Registered User
    Join Date
    09-24-2009
    Location
    Middletown, CT
    MS-Off Ver
    Excel 2003
    Posts
    31

    Record change only if it is text

    Hi,

    I'm trying to have a cell record the daystamp when another is changed. However, I only want to record it if the letter "A" is inputted in the column and if anything else is inputted, nothing happens. Right it records everything. Reason is so I can calculate time difference.

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim r      As Long
        Application.EnableEvents = False
        If Not Intersect(Target, Range("G:G")) Is Nothing And _
            Target.Columns.Count < Columns.Count Then
            On Error Resume Next
            For Each cell In Intersect(Target, Range("G:G"))
                cell.Offset(0, 54) = Format(Date, "MM/DD")
            Next cell
        End If
        Application.EnableEvents = True
    End Sub
    Figured it out. Just had to put an IF loop statement.

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim r      As Long
        On Error Resume Next
        Application.EnableEvents = False
        If Not Intersect(Target, Range("G2:G2000")) Is Nothing And _
            Target.Columns.Count < Columns.Count Then
            On Error Resume Next
            For Each cell In Intersect(Target, Range("G2:G2000"))
                If cell.Value = "A" Then
                cell.Offset(0, 54) = Format(Date, "MM/DD/YY")
                cell.Offset(0, 62) = Format(Date, "MM/DD/YY")
                ElseIf cell.Value = "M" Then
                cell.Offset(0, 56) = Format(Date, "MM/DD/YY")
                cell.Offset(0, 62) = Format(Date, "MM/DD/YY")
                ElseIf cell.Value = "AI" Then
                cell.Offset(0, 58) = Format(Date, "MM/DD/YY")
                cell.Offset(0, 62) = Format(Date, "MM/DD/YY")
                End If
            Next cell
        End If
        Application.EnableEvents = True
    End Sub
    Last edited by aznprod517; 11-19-2009 at 12:11 PM.

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