Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default copy rows that do not match values in dynamic range.

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default copy rows that do not match values in dynamic range.

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).E nd(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!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default copy rows that do not match values in dynamic range.

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).E nd(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
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
Match Values in Rows with Partial Values in Columns ryguy7272 Excel Worksheet Functions 3 August 8th 07 05:14 PM
Dynamic Range, Data Validation and Address, Match and Offset Funct rudawg Excel Worksheet Functions 3 January 29th 06 03:19 AM
Test IF Two Numeric Values Match (from two separate Dynamic Ranges) Sam via OfficeKB.com Excel Worksheet Functions 3 August 14th 05 12:20 AM
copy exact values from RangeA to Range B which has extra rows guptasa@gossami .com Excel Discussion (Misc queries) 1 May 16th 05 09:21 AM
How do i compare values from two sheet and copy & paste if values match? rozb Excel Programming 0 March 5th 04 12:06 AM


All times are GMT +1. The time now is 12:21 PM.

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

About Us

"It's about Microsoft Excel"