Hi all,
Hope you can help, I have a second hand spreadhsheet, that I have kind of butchered, and managed to get working, but i'm having a bit of a problem with one piece of the code. The spreadsheet can search and return a line of data based on the unique key (in column A), and then this data can be amended and saved, but when it is saving, it should delete the first line of data, and just leave the newly saved data, but at the moment it is saving the data, but not deleting the original line. It will always be the newest line of data that is to be deleted.
This is the code that is currently in the spreadsheet, any help would be appreciated.
Daz
Hope you can help, I have a second hand spreadhsheet, that I have kind of butchered, and managed to get working, but i'm having a bit of a problem with one piece of the code. The spreadsheet can search and return a line of data based on the unique key (in column A), and then this data can be amended and saved, but when it is saving, it should delete the first line of data, and just leave the newly saved data, but at the moment it is saving the data, but not deleting the original line. It will always be the newest line of data that is to be deleted.
This is the code that is currently in the spreadsheet, any help would be appreciated.
Daz
Code:
Application.ScreenUpdating = False
Sheets("Data").Select
Const lookup_column As String = "a"
Dim i As Long
Dim LastRow As Long
Dim LastRows As Long
Dim cell As Range
Dim sh As Worksheet
With ActiveSheet
LastRow = .Cells(.Rows.Count, lookup_column).End(xlUp).Row
For i = LastRow - 1 To 2 Step -1
If Application.CountIf(.Cells(i, lookup_column).Resize(LastRow - i + 1), .Cells(i, lookup_column)) > 1 Then
.Rows(i).Delete
End If
Next i
LastRows = WorksheetFunction.CountA(Range("a:a"))
Worksheets("INPUT PAGE").Range("E144").Value = LastRows
End With
'
ActiveWorkbook.Save
Sheets("Front Page").Select
Range("a75").Select
Application.ScreenUpdating = True