VBA - Delete rows in a column if value starts with "A"

MrManBoy

New Member
Joined
May 28, 2014
Messages
37
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Gday All :-)

I am hoping if anyone could kindly please assist.

Trying to achieve: VBA to delete all rows in a specific column i.e "A", where the value begins with ","

Example Data:

[TABLE="class: outer_border, width: 200, align: left"]
<tbody>[TR]
[TD="align: center"]Column A
[/TD]
[/TR]
[TR]
[TD]Bloggs, Joe
[/TD]
[/TR]
[TR]
[TD]Doe, John
[/TD]
[/TR]
[TR]
[TD], Sam
[/TD]
[/TR]
[TR]
[TD], Matt
[/TD]
[/TR]
</tbody>[/TABLE]









Hopefully that does make sense, if not let me know what further info is required.

Thank you :biggrin:
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hey Steve - Thanks for the reply.

Reason for using VBA is to make this part of a group of automated tasks not for myself (I'm just the one tasked with outting this togeher, God knows why).

:eeek:
 
Upvote 0
One-way...

Rich (BB code):
Sub xxx()
    Dim LstRw As Long, i As Long
    Application.ScreenUpdating = False
    LstRw = Range("A" & Rows.Count).End(xlUp).Row
    
    For i = LstRw To 1 Step -1
        If Left(Cells(i, 1), 1) = "," Then Cells(i, 1).EntireRow.Delete
    Next
    
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
Solution
Another way,

Code:
Sub Delete_Row()
On Error Resume Next
With Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
    .Replace ",*", "#N/A", xlWhole
    .SpecialCells(xlCellTypeConstants, xlErrors).EntireRow.Delete
End With
End Sub
 
Upvote 0
Mark858 & VDS1 - Thank you both for your assistance, both codes work like a charm!

Really appreciate the help!
:beerchug:
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,100
Members
452,301
Latest member
QualityAssurance

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top