Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Delete Rows from sheet 1 from values in sheet 2

Hi,

Sheet 2 has the values

A B
1 CAR BUS
2
3

Sheet 1 Has

A B
1 BUS
2 TRAIN
3 CAR
4 BIKE
5 BUS

I want to programatically select as a range CAR BUS (sheet 2) and delete
other entire rows in sheet 2

i.e

A B
1 BUS
2 CAR
3 BUS

Thanks for all future help

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200911/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Delete Rows from sheet 1 from values in sheet 2

dim source as range
dim basedata as string
set source = worksheets("sheet2").Range("A1")
do until source = ""
basedata = basedata & "," & source.Value
set source = sourcde.Offset( ,1)
loop
set source = worksheets("sheet1").Range("B1").End(xlDown)
do
if Instr(basedata,source) =0 then
worksheets("sheet1").Rows(source.row).Delete
end if
if source.row=1 then exit do
set source = source.offset(-1)
loop

' basedata will be a concatenated string of your sheet2 row..."CAR,BUS"
the second loop reads each item and checks if its in the list, eg
instr("CAR,BUS","BUS") will = 5 while
instr("CAR,BUS","DOG") will be zero, and that row deleted




"FIRSTROUNDKO via OfficeKB.com" <u15639@uwe wrote in message
news:9fb26cce03583@uwe...
Hi,

Sheet 2 has the values

A B
1 CAR BUS
2
3

Sheet 1 Has

A B
1 BUS
2 TRAIN
3 CAR
4 BIKE
5 BUS

I want to programatically select as a range CAR BUS (sheet 2) and delete
other entire rows in sheet 2

i.e

A B
1 BUS
2 CAR
3 BUS

Thanks for all future help

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200911/1

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
Delete values in sheet 2 that arre found in sheet 1 np Excel Discussion (Misc queries) 1 December 10th 09 07:21 PM
Hide rows of one sheet based on values in another sheet? Andrew Raastad Excel Programming 2 June 23rd 09 11:11 PM
Delete rows from one sheet containing deatils on the second sheet [email protected] New Users to Excel 4 September 6th 07 11:10 AM
Delete rows at end of sheet Evan Weiner Excel Discussion (Misc queries) 2 July 11th 07 08:48 PM
Cut filtered rows, paste into next empty row of new sheet, and delete cut rows Scott Excel Worksheet Functions 0 December 13th 06 01:25 AM


All times are GMT +1. The time now is 10:23 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"