Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copying Conditional formatting | Excel Discussion (Misc queries) | |||
Copying & Inserting Rows w/o Affecting other Rows Etc. | Excel Worksheet Functions | |||
Copying multiple rows to other worksheets (but amount of rows varies) - How? | Excel Discussion (Misc queries) | |||
Copying a Conditional Sum | Excel Discussion (Misc queries) | |||
Copying Rows when hiding other rows | Excel Worksheet Functions |