Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel VBA - can't delete proper row question

Posted on 2003-12-09
3
Medium Priority
?
232 Views
Last Modified: 2010-05-01
What i'm trying to do is run through a bunch of rows and for each instance of the word "Mike", I want to delete that row. Problem is, I can't figure out which row i'm on. I know i'm only missing a line or two and some assistance would be greatly appreciated.

Sub testing()

For Each i In Worksheets("Sheet1").Range("A1:A10").Cells
If i.Value = "Mike" Then
' WHAT ROW AM I ON?????
' HOW DO I PASS IT SO I CAN DELETE IT?
ActiveCell.EntireRow.Delete
End If
Next


End Sub

0
Comment
Question by:KABOOM
3 Comments
 
LVL 9

Accepted Solution

by:
malharone earned 200 total points
ID: 9908477
i did nt have an editor ... hope my syntax is right

dim x as integer=1  '<-- i think excel still uses 1 based indexing
dim MAX_SEARCH_ITEMS as integer=1000
While x<MAX_SEARCH_ITEMS
  if worksheets("sheet1").range("A" & x).value ="MIKE" then
       activecell.entirerow.delete
  else
       x+=1
  endif
Wend


hope this helps
0
 
LVL 27

Expert Comment

by:planocz
ID: 10235428
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
No response from KABOOM from 12/09/2003 comment
Award points to malharone is recommend.
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

planocz
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question