Hello,
I have a script that moves data from one sheet to another based on a criteria-- thanks to the help I got on this board . It moves what I need perfectly, BUT It is supposed to move below the last line of data -line 232 for this so it should go to line 233, but is going to line 5004. I can sort them into order but the next time data moves it goes to line 5005 not 234. I tried to clearing the lines, deleting the empty lines on the Data history tab, and it just keeps progressing after the last line in the 5000s. I am stumped.
Sub Move_Data()
'
' Move_Data Macro
' Move Data
'
' Keyboard Shortcut: Ctrl+Shift+M
'
ActiveSheet.Unprotect Password:="123"
Worksheets("DataHistory").Unprotect Password:="123"
Dim Check As Range, r As Long, lastrow2 As Long, lastrow As Long
Application.ScreenUpdating = False
lastrow = ActiveWorkbook.ActiveSheet.UsedRange.Rows.Count
lastrow2 = Worksheets("DataHistory").UsedRange.Rows.Count
If lastrow2 = 1 Then lastrow2 = 1
For r = lastrow To 2 Step -1
If Range("F" & r).Value = "Not Eligible" Or Range("I" & r).Value >= (1 / 1 / 80) Or Range("K" & r).Value >= (1 / 1 / 80) Or Range("L" & r).Value >= (1 / 1 / 80) Then
Rows(r).Cut Destination:=Worksheets("DataHistory").Range("a" & lastrow2 + 1)
Rows(r).Delete
lastrow2 = lastrow2 + 1
Else:
End If
Next r
Application.ScreenUpdating = True
Worksheets("DataHistory").Range("A1:N5000").Locked = True <<NOTE also tried Range(A:N)>>
Worksheets("DataHistory").Protect Password:="123"
ActiveSheet.Protect Password:="123"
End Sub
I have a script that moves data from one sheet to another based on a criteria-- thanks to the help I got on this board . It moves what I need perfectly, BUT It is supposed to move below the last line of data -line 232 for this so it should go to line 233, but is going to line 5004. I can sort them into order but the next time data moves it goes to line 5005 not 234. I tried to clearing the lines, deleting the empty lines on the Data history tab, and it just keeps progressing after the last line in the 5000s. I am stumped.
Sub Move_Data()
'
' Move_Data Macro
' Move Data
'
' Keyboard Shortcut: Ctrl+Shift+M
'
ActiveSheet.Unprotect Password:="123"
Worksheets("DataHistory").Unprotect Password:="123"
Dim Check As Range, r As Long, lastrow2 As Long, lastrow As Long
Application.ScreenUpdating = False
lastrow = ActiveWorkbook.ActiveSheet.UsedRange.Rows.Count
lastrow2 = Worksheets("DataHistory").UsedRange.Rows.Count
If lastrow2 = 1 Then lastrow2 = 1
For r = lastrow To 2 Step -1
If Range("F" & r).Value = "Not Eligible" Or Range("I" & r).Value >= (1 / 1 / 80) Or Range("K" & r).Value >= (1 / 1 / 80) Or Range("L" & r).Value >= (1 / 1 / 80) Then
Rows(r).Cut Destination:=Worksheets("DataHistory").Range("a" & lastrow2 + 1)
Rows(r).Delete
lastrow2 = lastrow2 + 1
Else:
End If
Next r
Application.ScreenUpdating = True
Worksheets("DataHistory").Range("A1:N5000").Locked = True <<NOTE also tried Range(A:N)>>
Worksheets("DataHistory").Protect Password:="123"
ActiveSheet.Protect Password:="123"
End Sub