PC Review


Reply
Thread Tools Rate Thread

Conditional copying of rows

 
 
Gert-Jan
Guest
Posts: n/a
 
      10th Dec 2006
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 With Quote
 
 
 
 
Tom Ogilvy
Guest
Posts: n/a
 
      10th Dec 2006
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
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting certain Rows and Copying cells in those rows to new work Jinx123 Microsoft Excel Programming 1 8th Jun 2010 01:47 PM
insert rows and copying cells in column b,c, and d into new rows gbpg Microsoft Excel Programming 3 31st Dec 2009 01:05 AM
Copying a conditional formating rows with text and values Iraj Microsoft Excel Programming 2 16th Feb 2009 11:33 AM
Copying the filtered data to clipboard is copying non-visible rows =?Utf-8?B?U2VldGhhUmFtYW4=?= Microsoft Excel Crashes 10 12th Jul 2006 09:39 PM
Copying multiple rows to other worksheets (but amount of rows varies) - How? David Smithz Microsoft Excel Misc 1 18th Jun 2006 04:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:32 AM.