LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default best way to query during macro run

This should do it. Assumes the data starts on row 2:


Code
-------------------
Sub DeleteAllBut7()

Dim i As Long
Dim iStart As Long
Dim iEnd As Long

iStart = 2 'Assumes data starts on row 2
iEnd = Range("B65536").End(xlUp).Row

For i = iStart To iEnd
If Range("B" & i).Value < "Name1" And _
Range("B" & i).Value < "Name2" And _
Range("B" & i).Value < "Name3" And _
Range("B" & i).Value < "Name4" And _
Range("B" & i).Value < "Name5" And _
Range("B" & i).Value < "Name6" And _
Range("B" & i).Value < "Name7" Then
Range("B" & i).Value = ""
End If
Next

Range("B" & iStart & ":B" & iEnd).SpecialCells(xlCellTypeBlanks).EntireRow.Del ete

End Su
-------------------

It basically sets the B column to a blank if the name doesn't exist
then deletes all rows with blanks in column B.



--
Message posted from http://www.ExcelForum.com

 
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
Macro Query rmsmith Excel Discussion (Misc queries) 1 December 15th 09 06:32 PM
Macro Query shakey1181 Excel Discussion (Misc queries) 3 July 24th 07 07:55 PM
another macro query - deleting a worksheet within a query DavidHawes Excel Discussion (Misc queries) 2 February 26th 07 10:05 AM
NEW WEB QUERY MACRO A.J Setting up and Configuration of Excel 0 July 24th 05 04:31 AM
Web Query in Macro buckle Excel Programming 0 August 19th 03 10:01 PM


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