ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   MACRO which deletes a row, when it finds a specific number (https://www.excelbanter.com/excel-discussion-misc-queries/168211-macro-deletes-row-when-finds-specific-number.html)

Spiros

MACRO which deletes a row, when it finds a specific number
 
Hi,

I want to create a macro which find one specific number in the column B and
delete the row.
For example: There is the number 60 in the cell B15 by accident. The macro
will delete the row No 15.

Thanks in advance,
Spiros



Pete_UK

MACRO which deletes a row, when it finds a specific number
 
You could apply autofilter to column B, select 60 from the drop-down,
highlight the visible rows and Edit | Delete Row. Then select All from
the drop-down.

Hope this helps.

Pete

On Dec 3, 7:51 am, Spiros wrote:
Hi,

I want to create a macro which find one specific number in the column B and
delete the row.
For example: There is the number 60 in the cell B15 by accident. The macro
will delete the row No 15.

Thanks in advance,
Spiros



Don Guillett

MACRO which deletes a row, when it finds a specific number
 
Record a macro using editfind. If you want more than one use findnext

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Spiros" wrote in message
...
Hi,

I want to create a macro which find one specific number in the column B
and
delete the row.
For example: There is the number 60 in the cell B15 by accident. The macro
will delete the row No 15.

Thanks in advance,
Spiros




Spiros

MACRO which deletes a row, when it finds a specific number
 
Guys thank you for your suggestions.
I find this macro end it works.

Sub testme02()

Dim myRng As Range
Dim FoundCell As Range
Dim wks As Worksheet
Dim myStrings As Variant
Dim iCtr As Long

myStrings = Array("60") 'add more strings if you need

Set wks = ActiveSheet

With wks
Set myRng = .Range("b2:b" & .Rows.Count)
End With

For iCtr = LBound(myStrings) To UBound(myStrings)
Do
With myRng
Set FoundCell = .Cells.Find(what:=myStrings(iCtr), _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
lookat:=xlWhole, _
searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
Exit Do
Else
FoundCell.EntireRow.Delete
End If
End With
Loop
Next iCtr
End Sub

Ο χρήστης "Don Guillett" *γγραψε:

Record a macro using editfind. If you want more than one use findnext

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Spiros" wrote in message
...
Hi,

I want to create a macro which find one specific number in the column B
and
delete the row.
For example: There is the number 60 in the cell B15 by accident. The macro
will delete the row No 15.

Thanks in advance,
Spiros






All times are GMT +1. The time now is 03:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com