Solved

Excel VBA - can't delete proper row question

Posted on 2003-12-09
3
223 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now