This should be simple....I just can't seem to get it to run right.
Goal: Pull in column A from Sheet1 to Sheet 2 (starting at Row 2) where Sheet1 Column BR (70)> 0 AND Column N (14) = Var1/2/3.
Issue: Currently it does pull in the correct rows, but it pulls them in at the same row number from Sheet1 into Sheet2. I would like it to start at Row 2 and then go from there. I'm sure an Array would probably speed this up, but I want to get the proof of concept before adding that.
Code:
Thanks for any help or advice you can lend. I feel like this should be easy, but I've been looking at it for several hours to no avail....
Goal: Pull in column A from Sheet1 to Sheet 2 (starting at Row 2) where Sheet1 Column BR (70)> 0 AND Column N (14) = Var1/2/3.
Issue: Currently it does pull in the correct rows, but it pulls them in at the same row number from Sheet1 into Sheet2. I would like it to start at Row 2 and then go from there. I'm sure an Array would probably speed this up, but I want to get the proof of concept before adding that.
Code:
VBA Code:
Sub add_NY_totals()
Dim r As Long
Dim y As Long
'For r = 2 To Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
For r = 2 To 200
If Sheets("Sheet1").Cells(r, 14) = "Var1" Or _
Sheets("Sheet1").Cells(r, 14) = "Var2" Or _
Sheets("Sheet1").Cells(r, 14) = "Var4" Or _
Sheets("Sheet1").Cells(r, 14) = "Var5" _
Then
Sheets("Sheet1").Cells(r, "BR") = WorksheetFunction.Sum(Range("AG" & r & ":AR" & r))
End If
Next r
For y = 2 To 200
If Sheets("Sheet1").Cells(y, "BR") > 0 And _
Sheets("Sheet1").Cells(y, 14) = "Var1" Or _
Sheets("Sheet1").Cells(y, 14) = "Var2" Or _
Sheets("Sheet1").Cells(y, 14) = "Var4" _
Then
Sheets("Sheet2").Cells(y, 1).Value = Sheets("Sheet1").Cells(y, 1)
End If
Next y
End Sub
Thanks for any help or advice you can lend. I feel like this should be easy, but I've been looking at it for several hours to no avail....