Computing.Net > Forums > Programming > Excel Macro Delete Record

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Excel Macro Delete Record

Reply to Message Icon

Name: Flaming
Date: September 2, 2004 at 06:59:22 Pacific
OS: WIN XP SP1
CPU/Ram: P4 3.0 / 1G R
Comment:

I'll explain what I'm trying to do using a simple example.

Let's say I have a 100 records in my excel sheet. In, for example, 10 of those records is a specific word. Let's say "Dean". What I would like is that every record (not just the cell) that contains the word "Dean" is deleted using a Marco. So that would leave me with only 90 records as end result.

Thx



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: September 5, 2004 at 10:26:02 Pacific
Reply:

Hi
Are these records in one column and do you want to delete the records and leave them blank or move the other records up, so there is no blanks rows.


0

Response Number 2
Name: Flaming
Date: September 16, 2004 at 02:50:41 Pacific
Reply:

No in different column's and indeed I want to shift the cells up so there are no blank rows.


0

Response Number 3
Name: dtech10
Date: September 17, 2004 at 06:57:22 Pacific
Reply:

Hi
Im no expert with Excel, but will this help
Just select all the cells and run the macro.
Try it on a dummy spreadsheet first, so as not to upset your records.
Hope this helps
-----------
Option Explicit
' Delete "Dean" from Selected Range.

Sub DelDeans()
Dim Row As Integer
Dim Max As Integer
Dim Record As Range

Max = Selection.Count
Set Record = Selection

Row = 1
Do
If InStr(LCase$(Record.Cells(Row)), "dean") Then
Record.Cells(Row).EntireRow.Delete
End If
Row = Row + 1
Loop Until Row > Max
End Sub


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


VB scrollbar combining excel pages wit...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Excel Macro Delete Record

Excel macro problem: Cell ranges www.computing.net/answers/programming/excel-macro-problem-cell-ranges/2800.html

Can I call an Excel macro from cell www.computing.net/answers/programming/can-i-call-an-excel-macro-from-cell/4812.html

Excel macro www.computing.net/answers/programming/excel-macro/9408.html