Excel existing code flaw

QualityAssurance

New Member
Joined
Oct 31, 2024
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Greetings,
I have an excel document that tracks items on a "to-do list", I have an active and historical tab. Active for anything that is still outstanding and the historical for anything that has been completed. I am running a code that will automatically transfer my active tasks to my historical tab once a date is entered into the "completed date" column. The issue I am having is that now that I have reached line 19 in my historical tab, the new items from the active tab continuously replace line 19 on the historical tab when transferring instead of continuing to add a new row. I am at a loss on what in the code is causing the glitch on line 19 specifically. Before it reached line 19 the rows of information would transfer and insert a new row each execution.

Here is my code:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.CountLarge = 1 And Target.Column = 8 Then
        Application.EnableEvents = False
        If IsDate(Target.Value) Then
            With Target.EntireRow
                .Copy Sheets("Historical Initiatives").Cells(Rows.Count, 1).End(xlUp).Offset(1)
                .Delete
            End With
        End If
    End If
    Application.EnableEvents = True
End Sub

Appreciate the help!
Thank you
 
Last edited by a moderator:
Try this
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.CountLarge = 1 And Target.Column = 8 Then
Application.EnableEvents = False
If IsDate(Target.Value) Then
With Target.EntireRow
.Copy Sheets("Historical Initiatives").Cells(Rows.End(xlUp).Row + 1, 1).
.Delete
End With
End If
End If
Application.EnableEvents = True
End Sub
I realized when I used your code it didn't apply it properly and I was testing my original code. Attempting again and making sure the code was applied it errors out and does not transfer any lines and takes me to the debugging wizard. Sorry for the misinformation at first, thanks for the help.
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
If you have no hidden rows on your Historical Initiatives sheet try....

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.CountLarge = 1 And Target.Column = 8 Then
        Application.EnableEvents = False
        If IsDate(Target.Value) Then
            With Target.EntireRow
                .Copy Sheets("Historical Initiatives").Cells.Find("*", , xlValues, , xlByRows, xlPrevious).Offset(1)
                .Delete
            End With
        End If
    End If
    Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,931
Messages
6,175,465
Members
452,646
Latest member
tudou

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top