Wish I would have learned about macros years ago! It's time to bring in the experts since can't figure it out or find a post that answers my issue.
I'm keeping rows with certain addresses and deleting all other rows. I'm trying to avoid having to type in each individual address and unit number in large buildings by using a wildcard for the unit number or letter.
i.e. 225-* E 6TH ST would find any unit number at 225 E 6TH ST that is listed in the report.
I found the formula below in a post but I can't get a wild card to work after the hyphen in the addresses with unit numbers. I've tried both * and ??? wildcards.
I trimmed the posted formula below down to a few addresses. Each week I run the formula there will be a large quantity of new addresses without and addresses with unit numbers to search through.
I'm keeping rows with certain addresses and deleting all other rows. I'm trying to avoid having to type in each individual address and unit number in large buildings by using a wildcard for the unit number or letter.
i.e. 225-* E 6TH ST would find any unit number at 225 E 6TH ST that is listed in the report.
I found the formula below in a post but I can't get a wild card to work after the hyphen in the addresses with unit numbers. I've tried both * and ??? wildcards.
I trimmed the posted formula below down to a few addresses. Each week I run the formula there will be a large quantity of new addresses without and addresses with unit numbers to search through.
VBA Code:
Sheets("Addresses01").Select
Range("A1").Select
Const lngStartRow As Long = 2 'Starting data row number. Change to suit.
Dim lngMyCol As Long, _
lngMyRow As Long
Dim xlnCalcMethod As XlCalculation
With Application
xlnCalcMethod = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
lngMyCol = Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 1
lngMyRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
With Columns(lngMyCol)
With Range(Cells(lngStartRow, lngMyCol), Cells(lngMyRow, lngMyCol))
.Formula = "=VLOOKUP(D2,{""715-A MULBERRY ST"";""715-F MULBERRY ST"";""225-100 E 6TH S"";""225-299 E 6TH ST""; ""3421-1 W 9TH ST"";; ""3421-30 W 9TH ST""},1,FALSE)"
ActiveSheet.Calculate
.Value = .Value
End With
On Error Resume Next 'Turn error reporting off - OK to ignore 'No cells found' message
.SpecialCells(xlCellTypeConstants, xlErrors).EntireRow.Delete
On Error GoTo 0 'Turn error reporting back on
.Delete
End With
With Application
.Calculation = xlnCalcMethod
.ScreenUpdating = True
End With
Cells.Select
Selection.Columns.AutoFit
Range("A1").Select
ActiveWorkbook.Save
' Stops automated process and waits for a key press if included - MsgBox "All rows where the status was not one of the desired statuses have now been deleted.", vbInformation