ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy rows from Sheet1 to Sheet2 when Column B values equal "X" andColumn C values 100 (https://www.excelbanter.com/excel-programming/443242-copy-rows-sheet1-sheet2-when-column-b-values-equal-x-andcolumn-c-values-100-a.html)

u473

Copy rows from Sheet1 to Sheet2 when Column B values equal "X" andColumn C values 100
 
How do I copy rows (Columns A,B,D only, values only) from Sheet1 to
Sheet2, same workbook.
when Column B values equal "X" and Column C values 100.
Help appreciated
J.P.

Don Guillett Excel MVP

Copy rows from Sheet1 to Sheet2 when Column B values equal "X"and Column C values 100
 
On Jun 21, 5:38*pm, u473 wrote:
How do I copy rows (Columns A,B,D only, values only) from Sheet1 to
Sheet2, same workbook.
*when Column B values equal "X" and Column C values 100.
Help appreciated
J.P.


Sub SAS_CopyValuesIF()
Dim r As Double
Dim i As Long
r = 16 'start row on destination sheet
For i = 1 To Cells(Rows.Count, "b").End(xlUp).Row
If UCase(Cells(i, 2)) = "X" And Cells(i, 3) 100 Then
Sheets("sheet4").Cells(r, 1).Value = Cells(i, 1).Value
Sheets("sheet4").Cells(r, 2).Value = Cells(i, 2).Value
Sheets("sheet4").Cells(r, 3).Value = Cells(i, 4).Value
r = r + 1
End If
Next i
End Sub

u473

Copy rows from Sheet1 to Sheet2 when Column B values equal "X"and Column C values 100
 
Thank you,
Well appreciated,
J.P.


All times are GMT +1. The time now is 05:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com