EKelley0311
New Member
- Joined
- Oct 3, 2014
- Messages
- 3
I'm currently working on a project that needs to move some rows marked with an "x" in one sheet to another sheet within the workbook. The code works except for the fact that it's not moving the selected rows to the other sheet. Instead, it's just replicating the rows in the same first sheet. I have a feeling that it's something simple that I'm just overlooking. Wanted to see if it stands out to anyone else. Thanks for any help! Here's the code....
Option Explicit
Sub CommandButton1_Click()
Dim i As Long
Dim y As Long
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim Ary1 As Range
Dim Ary2 As Range
Set ws1 = ActiveWorkbook.Sheets("SSAT")
Set ws2 = ActiveWorkbook.Sheets("Accrual Entry Sheet")
y = 15
For i = 2 To 100:
If ws1.Cells(i, 20) = "x" Then
ws1.Activate
Set Ary1 = Range(Cells(i, 1), Cells(i, 17))
ws2.Activate
Set Ary2 = Range(Cells(y, 1), Cells(y, 17))
Ary2.Value = Ary1.Value
y = y + 1
End If
Next i
MsgBox ("Done")
End Sub
Option Explicit
Sub CommandButton1_Click()
Dim i As Long
Dim y As Long
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim Ary1 As Range
Dim Ary2 As Range
Set ws1 = ActiveWorkbook.Sheets("SSAT")
Set ws2 = ActiveWorkbook.Sheets("Accrual Entry Sheet")
y = 15
For i = 2 To 100:
If ws1.Cells(i, 20) = "x" Then
ws1.Activate
Set Ary1 = Range(Cells(i, 1), Cells(i, 17))
ws2.Activate
Set Ary2 = Range(Cells(y, 1), Cells(y, 17))
Ary2.Value = Ary1.Value
y = y + 1
End If
Next i
MsgBox ("Done")
End Sub