Vba help

Isabella

Well-known Member
Joined
Nov 7, 2008
Messages
643
Hi in Column A Row R8 and below I have portfolios which start with ZI and FI, i need a code that will delete entire row in Col A which has pfolios starting with these 2 letters

<TABLE style="WIDTH: 64pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=85 border=0 x:str><COLGROUP><COL style="WIDTH: 64pt; mso-width-source: userset; mso-width-alt: 3108" width=85><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD class=xl96 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 64pt; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" width=85 height=17 x:str="ZISJHH"> ZISJHH </TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD class=xl96 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17 x:str="FIETRR"> FIETRR </TD></TR></TBODY></TABLE>
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try

Code:
Sub DL()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 8 Step -1
    With Range("A" & i)
        If .Value Like "ZI*" Or .Value Like "FI*" Then Rows(i).Delete
    End With
Next i
End Sub
 
Upvote 0
I'd use Autofilter-> Filter with an Or condition with a Wildcard (begins with) and delete the rows that the Autofilter returns. Data->Filters->Autofilter (from memory - I'm staring at a ribbon).
 
Upvote 0
Try

Code:
Sub DL()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 8 Step -1
    With Range("A" & i)
        If .Value Like "ZI*" Or .Value Like "FI*" Then Rows(i).Delete
    End With
Next i
End Sub

Vog i am trying to run this macro from Sheet Tasklist but its for sheet Downloads where the data is, is this correct, cos when i run the macro nothing happens.

With Sheets("Downloads")
LR = .Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 8 Step -1
With .Range("A" & i)
If .Value Like "ZI*" Or .Value Like "FI*" Then .Rows(i).Delete
End With
Next i
End With
 
Upvote 0
Try the following

Sub sortdata()

Dim lastrow As Long
lastrow = Cells(rows.Count, 1).End(xlUp).Row
For i = lastrow To 1 Step -1
l = Left(Cells(i, 1), 2)
If l = "ZI" Or l = "FI" Then
rows(i).Delete
Else
End If
Next i

End Sub
 
Upvote 0
Oops! Try

Code:
Sub DL()
Dim LR As Long, i As Long
With Sheets("Downloads")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    For i = LR To 8 Step -1
        With .Range("A" & i)
            If .Value Like "ZI*" Or .Value Like "FI*" Then .EntireRow.Delete
        End With
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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