Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying Conditional formatting gibbylynn Excel Discussion (Misc queries) 2 January 25th 10 05:09 PM
Copying & Inserting Rows w/o Affecting other Rows Etc. LRay67 Excel Worksheet Functions 1 October 22nd 08 02:10 AM
Copying multiple rows to other worksheets (but amount of rows varies) - How? David Smithz Excel Discussion (Misc queries) 1 June 18th 06 04:31 PM
Copying a Conditional Sum Ramakrishnan Rajamani Excel Discussion (Misc queries) 4 April 17th 05 05:36 PM
Copying Rows when hiding other rows Neutron1871 Excel Worksheet Functions 2 November 3rd 04 11:38 PM


All times are GMT +1. The time now is 06:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"