PC Review


Reply
Thread Tools Rate Thread

copy rows that do not match values in dynamic range.

 
 
=?Utf-8?B?WmVicmFoZWFk?=
Guest
Posts: n/a
 
      13th Mar 2007
Hi every one,

Please help vba/excel newbie!

I have 3 sheets with columns SKU and Quantity.
Sheet1 is raw data. Sheet2 is in house stock and Sheet3 is outside stock.

What I need is to loop through the rows in sheet1 and check if the SKU
exists in Sheet2 if not copy the row into Sheet3.

The problem is that the SKUs in Sheet2 (the one I'm matching against) change
all the time so I can't hard code them.

Thanks in advance for any advice!
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      13th Mar 2007
Sub copyrows()
Dim rng1 as Range, cell as Range
Dim sh1 as worksheet, sh2 as worksheet
dim sh3 as worksheet, rw as Long
set sh1 = worksheets("Sheet1")
set sh2 = worksheets("Sheet2")
set sh3 = worksheets("sheet3")
rw = sh3.cells(rows.count,1).End(xlup).row + 1
set rng1 = sh1.range(sh1.cells(2,1),sh1.cells(rows.count,1).End(xlup))
for each cell in rng1
if application.countif(sh2.columns(1),cell) = 0 then
cell.entireRow.copy sh3.rows(rw)
rw = rw + 1
end if
Next
End sub
--
Regards,
Tom Ogilvy


"Zebrahead" wrote:

> Hi every one,
>
> Please help vba/excel newbie!
>
> I have 3 sheets with columns SKU and Quantity.
> Sheet1 is raw data. Sheet2 is in house stock and Sheet3 is outside stock.
>
> What I need is to loop through the rows in sheet1 and check if the SKU
> exists in Sheet2 if not copy the row into Sheet3.
>
> The problem is that the SKUs in Sheet2 (the one I'm matching against) change
> all the time so I can't hard code them.
>
> Thanks in advance for any advice!

 
Reply With Quote
 
=?Utf-8?B?WmVicmFoZWFk?=
Guest
Posts: n/a
 
      13th Mar 2007
That works great. Thank you very much!!!

"Tom Ogilvy" wrote:

> Sub copyrows()
> Dim rng1 as Range, cell as Range
> Dim sh1 as worksheet, sh2 as worksheet
> dim sh3 as worksheet, rw as Long
> set sh1 = worksheets("Sheet1")
> set sh2 = worksheets("Sheet2")
> set sh3 = worksheets("sheet3")
> rw = sh3.cells(rows.count,1).End(xlup).row + 1
> set rng1 = sh1.range(sh1.cells(2,1),sh1.cells(rows.count,1).End(xlup))
> for each cell in rng1
> if application.countif(sh2.columns(1),cell) = 0 then
> cell.entireRow.copy sh3.rows(rw)
> rw = rw + 1
> end if
> Next
> End sub
> --
> Regards,
> Tom Ogilvy
>
>
> "Zebrahead" wrote:
>
> > Hi every one,
> >
> > Please help vba/excel newbie!
> >
> > I have 3 sheets with columns SKU and Quantity.
> > Sheet1 is raw data. Sheet2 is in house stock and Sheet3 is outside stock.
> >
> > What I need is to loop through the rows in sheet1 and check if the SKU
> > exists in Sheet2 if not copy the row into Sheet3.
> >
> > The problem is that the SKUs in Sheet2 (the one I'm matching against) change
> > all the time so I can't hard code them.
> >
> > Thanks in advance for any advice!

 
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
Match Values and Copy Rows K Microsoft Excel Programming 3 23rd Sep 2009 12:22 AM
delete rows that dont match values in named range J.W. Aldridge Microsoft Excel Programming 8 20th May 2009 10:40 PM
Match Values in Rows with Partial Values in Columns =?Utf-8?B?cnlndXk3Mjcy?= Microsoft Excel Worksheet Functions 3 8th Aug 2007 05:14 PM
copy exact values from RangeA to Range B which has extra rows =?Utf-8?B?Z3VwdGFzYUBnb3NzYW1pIC5jb20=?= Microsoft Excel Misc 1 16th May 2005 09:21 AM
How do i compare values from two sheet and copy & paste if values match? =?Utf-8?B?cm96Yg==?= Microsoft Excel Programming 0 5th Mar 2004 12:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:24 AM.