Thread: Sorting
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Sorting

to not delete both columns A and B on that row must contain the strings

set lastrow = cells(rows.count,1).End(xlup).row
for i = lastrow to 1 step -1
if instr(1,cells(i,1),"Whse: ", vbTextCompare) 0 and _
instr(1,cells(k,2),"Source: ", vbTextCompare) 0 then
' do nothing
else
if rng is nothing then
set rng = cells(i,1)
else
set rng = union(rng,cells(i,1))
end if
end if
Next
if not rng is nothing then
rng.Entirerow.Delete
End if

or
If either contains the specific string, then don't delete


set lastrow = cells(rows.count,1).End(xlup).row
for i = lastrow to 1 step -1
if instr(1,cells(i,1),"Whse: ", vbTextCompare) 0 or _
instr(1,cells(k,2),"Source: ", vbTextCompare) 0 then
' do nothing
else
if rng is nothing then
set rng = cells(i,1)
else
set rng = union(rng,cells(i,1))
end if
end if
Next
if not rng is nothing then
rng.Entirerow.Delete
End if

--
Regards,
Tom Ogilvy

"bodhisatvaofboogie" wrote:

I am trying to sort for some pretty specific stuff and delete everything
else.

Sort Column A for the letters Whse: ## and Column B for the letters Source:
###
the ###'s vary but I want everything with those letters in it selected and
EVERYTHING ELSE deleted. Make Sense?

EX:
If Column A has Whse: ## AND Column B has Source: ### Then Delete
everything else.

I know it's a mess and I'm getting nowhere. Any input would be GREATLY
appreciated. THANKS!!!