![]() |
Conditional copying of rows
Hi,
In sheetA (A1-P30) I have data. I want to copy some data from this sheet to sheet2. Condiotions: macro must look in column B for a specific value and in column P as well. Rows that have both values (textbox1 and textbox2 of my userform) must be copied. Can someone help? Thanks in advance. Regards, Gert-Jan |
Conditional copying of rows
Private Sub Commandbutton1_click()
Dim cell as Range, rng as Range for each cell in Worksheets("SheetA").Range("A1:A30") If lcase(cell.offset(0,1).Value) = lcase(Userform1.TextBox1.Value) and _ lcase(cell.offset(0,15).Value) = lcase(Userform1.TextBox2.Value) then if rng is nothing then set rng = cell else set rng = union(rng,cell) end if end if Next if not rng is nothing then rng.EntireRow.copy Worksheets("SheetB").Range("A1") End if end sub -- Regards, Tom Ogilvy "Gert-Jan" wrote in message .. . Hi, In sheetA (A1-P30) I have data. I want to copy some data from this sheet to sheet2. Condiotions: macro must look in column B for a specific value and in column P as well. Rows that have both values (textbox1 and textbox2 of my userform) must be copied. Can someone help? Thanks in advance. Regards, Gert-Jan |
All times are GMT +1. The time now is 05:01 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com