我在地址栏
上删除APT
和 STE
后的所有内容时遇到问题
如果你看一下结果,我的vba代码就是删除字母 ste ( 2121 STE VENSON LN )或的易于
在此之后删除APT或STE以及所有内容的最佳方法是什么?
以下是我的代码,
Option Explicit
Sub Remove()
Dim Sht As Worksheet
Set Sht = ActiveWorkbook.Sheets("Data")
With Sht.Range("E:E")
.Replace "APT*", "", xlPart
.Replace "STE*", "", xlPart
End With
End Sub
我的数据
+-------+-----+-----+----------+----------------------------------+-------+------+-----+
| Route | Pcs | Wgt | Location | Address | Suite | City | Zip |
+-------+-----+-----+----------+----------------------------------+-------+------+-----+
| SD-26 | 1 | 3 | | 5555 SOUTHWESTERN BLVD | | | |
| SD-26 | 1 | 7 | | 6666 EASTERN AVE APT 100 | | | |
| SD-05 | 1 | 1 | | 161112 HOMESTEAD ST | | | |
| SD-05 | 2 | 8 | | 2221 STEVENSON LN | | | |
| SD-04 | 1 | 8 | | 4040 OLD DENTON RD APT 2104 | | | |
| SD-04 | 1 | 3 | | 15811 E FRANKFORD RD APT 1507 | | | |
| SD-04 | 1 | 1 | | 835 WESTMINSTER DR | | | |
| SD-03 | 1 | 5 | | 9001 LAKESIDE CIR APT 5203 | | | |
| SD-03 | 1 | 3 | | 8880 UNION STATION PKWY APT 2104 | | | |
| SD-03 | 1 | 1 | | 420 E MAIN ST STE E | | | |
+-------+-----+-----+----------+----------------------------------+-------+------+-----+
结果
+-------+-----+-----+----------+--------------------------+-------+------+-----+
| Route | Pcs | Wgt | Location | Address | Suite | City | Zip |
+-------+-----+-----+----------+--------------------------+-------+------+-----+
| SD-26 | 1 | 3 | | 5555 SOUTHWE | | | |
| SD-26 | 1 | 7 | | 6666 EA | | | |
| SD-05 | 1 | 1 | | 161112 HOME | | | |
| SD-05 | 2 | 8 | | 2221 | | | |
| SD-04 | 1 | 8 | | 4040 OLD DENTON RD | | | |
| SD-04 | 1 | 3 | | 15811 E FRANKFORD RD | | | |
| SD-04 | 1 | 1 | | 835 WESTMIN | | | |
| SD-03 | 1 | 5 | | 9001 LAKESIDE CIR | | | |
| SD-03 | 1 | 3 | | 8880 UNION STATION PKWY | | | |
| SD-03 | 1 | 1 | | 420 E MAIN ST | | | |
+-------+-----+-----+----------+--------------------------+-------+------+-----+