+ Reply to Thread
Results 1 to 4 of 4

inserting/deleting rows without registering cell change

Hybrid View

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

    inserting/deleting rows without registering cell change

    Hello,

    I got help on this a bit earlier, but right now a new problem has cropped up. I can insert lines fine, but the problem is that now I want the worksheet to be able to delete rows without inputting time stamps. It can insert them with no problems. I have attached the file on as well.

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim r As Long
        
        If Not Intersect(Target, Range("H2:H2000")) Is Nothing Then
            Application.EnableEvents = False
            On Error Resume Next
                For Each cell In Intersect(Target, Range("H2:H2000"))
                cell.Offset(0, -2) = Format(Now(), "HH:MM AM/PM")
                cell.Offset(0, -3) = Format(Now(), "MM/DD/YY")
            Next cell
        End If
        If Target.Columns.Count = Columns.Count Then
            For r = 1 To Target.Rows.Count
                Cells(Target(1).Row - 1, "C").Copy Cells(Target(1).Row + r - 1, "C")
                Cells(Target(1).Row - 1, "D").Copy Cells(Target(1).Row + r - 1, "D")
                Cells(Target(1).Row - 1, "I").Copy Cells(Target(1).Row + r - 1, "I")
                Cells(Target(1).Row - 1, "J").Copy Cells(Target(1).Row + r - 1, "J")
                Cells(Target(1).Row - 1, "K").Copy Cells(Target(1).Row + r - 1, "K")
            Next r
        End If
        Application.EnableEvents = True
    End Sub
    Thanks for your help
    Attached Files Attached Files
    Last edited by aznprod517; 10-30-2009 at 11:37 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: inserting/deleting rows without registering cell change

    Is this what you mean
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim r      As Long
        Application.EnableEvents = False
        If Not Intersect(Target, Range("H2:H2000")) Is Nothing And _
            Target.Columns.Count < Columns.Count Then
            On Error Resume Next
            For Each cell In Intersect(Target, Range("H2:H2000"))
                cell.Offset(0, -2) = Format(Now, "HH:MM AM/PM")
                cell.Offset(0, -3) = Format(Date, "MM/DD/YY")
            Next cell
        End If
        If Target.Columns.Count = Columns.Count Then
            For r = 1 To Target.Rows.Count
                Cells(Target(1).Row - 1, 3).Copy Cells(Target(1).Row + r - 1, 3)
                Cells(Target(1).Row - 1, 4).Copy Cells(Target(1).Row + r - 1, 4)
                Cells(Target(1).Row - 1, 9).Copy Cells(Target(1).Row + r - 1, 9)
                Cells(Target(1).Row - 1, 10).Copy Cells(Target(1).Row + r - 1, 10)
                Cells(Target(1).Row - 1, 11).Copy Cells(Target(1).Row + r - 1, 11)
            Next r
        End If
        Application.EnableEvents = True
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

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

    Re: inserting/deleting rows without registering cell change

    Yes that is exactly what I was looking for.

    Thank you for your help!

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: inserting/deleting rows without registering cell change

    no problem.

+ 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