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" <(E-Mail Removed)> wrote in message
news:457c25ca$0$26205$(E-Mail Removed)...
> 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
>
|