Deleting All Rows with Bad Cusips for All Sheets

ismphoto123

New Member
Joined
Nov 2, 2015
Messages
13
Hello,

I've been fiddling around with multiple codes and macros but none that are working. I have an excel macro that pulls in data, then we run another macro on that excel sheet. When it pulls in data, for whatever reason it is pulling in bad cusips.

So what I need to do is search all sheets AFTER the first sheet (new sheets are generated every time the macro is run so I can't go by sheet name) and delete ALL rows that contain "BASKET". The tricky part is that all of the bad cusips begin with BASKET then have another number. For example, BASKET32323232 and BASKET52655316136.

I just want to add this code to the existing code so it performs AFTER the data is pulled in, OR serves as a separate macro button that can be chosen.


<tbody>
</tbody><colgroup><col></colgroup>
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
also sheets(3) will always find the third sheet, regardless of the actual names given to the sheets.
 
Upvote 0
A cusip is just an identifier, the spreadsheet contains over 10,000 of them. About 9,000 are bad and need to be deleted. All located in Column AV in all spreadsheets after the first one.

Also, there could be six sheets or there could be two.
 
Upvote 0
train1
bag3
bus99
tax144
the original list as shown below was in cells K1:K6
we require to delete entire row if K column starts with "basket"
train1
basket45
bag3
bus99
basket999
tax144
achieved with this very simple macro
For j = 1 To 6
If Left(Cells(j, 11), 6) = "basket" Then Rows(j).Select: Selection.Delete Shift:=xlUp
Next j
Cells(1, 1).Select
100 End Sub

<colgroup><col width="64" span="12" style="width:48pt"> </colgroup><tbody>
</tbody>
 
Upvote 0
the macro looks for any cell in a particular column that has (in this case) "basket" as the first 6 letters and for each one found that row is deleted
 
Upvote 0
But the thing that i'm struggling with most is that my original macro populates sheets based on each Fund requested from the macro (could be 2, could be 6 or more). So is there anyway I can edit this so it will affect all sheets except the first one?
 
Upvote 0
Hi, you could try this on a copy of your workbook.

Code:
Sub M()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ThisWorkbook.Worksheets
    If ws.Index > 1 Then
        ws.Columns("AV").Replace What:="BASKET*", Replacement:="#N/A", MatchCase:=False
        On Error Resume Next
        ws.Columns("AV:AV").SpecialCells(xlCellTypeConstants, 16).EntireRow.Delete
        On Error GoTo 0
    End If
Next ws
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,155
Messages
6,123,335
Members
449,098
Latest member
thnirmitha

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