Hello,
I need assistance with VBA to move a row to another sheet.
I have 300+ rows of data in a sheet called "MASTER". A status marker (A or X) is placed in column T. When an X is placed in column T, I would like the entire row (including blanks to save structure) to be moved to the sheet called, "Inactive". I have a code inserted, but it's not working. It is moving the entire set of data to the other sheet, not just a single row. It's also leaving the original data and not deleting it after pasting to the other sheet.
It's in conjunction with another (working) code that is very important for the file, and maybe that's the issue. I have the first working code in the part that's worksheet specific and the one that's malfunctioning is in a module.
I am extremely inexperienced in VBA and I'm not sure how to fix this.
Any help is appreciated!
Code is pasted below:
Thanks!!!
Option ExplicitSub Hutton()
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Sheets("MASTER")
Set s2 = Sheets("Inactive")
Dim lr As Long, lr2 As Long
Dim i As Long
lr = s1.Range("T" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For i = 2 To lr
lr2 = s2.Range("A" & Rows.Count).End(xlUp).Row
If s1.Range("T" & i) = "A" Or s1.Range("T" & i) = "X" Then
s1.Range("T" & i).EntireRow.Copy s2.Range("A" & lr2 + 1)
End If
Next i
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
I need assistance with VBA to move a row to another sheet.
I have 300+ rows of data in a sheet called "MASTER". A status marker (A or X) is placed in column T. When an X is placed in column T, I would like the entire row (including blanks to save structure) to be moved to the sheet called, "Inactive". I have a code inserted, but it's not working. It is moving the entire set of data to the other sheet, not just a single row. It's also leaving the original data and not deleting it after pasting to the other sheet.
It's in conjunction with another (working) code that is very important for the file, and maybe that's the issue. I have the first working code in the part that's worksheet specific and the one that's malfunctioning is in a module.
I am extremely inexperienced in VBA and I'm not sure how to fix this.
Any help is appreciated!
Code is pasted below:
Thanks!!!
Option ExplicitSub Hutton()
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Sheets("MASTER")
Set s2 = Sheets("Inactive")
Dim lr As Long, lr2 As Long
Dim i As Long
lr = s1.Range("T" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For i = 2 To lr
lr2 = s2.Range("A" & Rows.Count).End(xlUp).Row
If s1.Range("T" & i) = "A" Or s1.Range("T" & i) = "X" Then
s1.Range("T" & i).EntireRow.Copy s2.Range("A" & lr2 + 1)
End If
Next i
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub