新浪博客

#Excel VBA#删除含特定字符的单元格及下方单元格上移

2014-09-11 11:09阅读:
1、需求目的:获取App Annie 上Google Play的榜单。
2、存在问题:从图1到图2,复制图1的榜单到Excel会出现特定字符,导致排序混乱。
3、解决问题:删除特定字符,且下方单元格上移。
具体如下:
图1:App Annie 上Google Play的榜单
#Excel <wbr>VBA#删除含特定字符的单元格及下方单元格上移
图2:复制图1到Excel表中的格式如下。
#Excel <wbr>VBA#删除含特定字符的单元格及下方单元格上移



以下是Excel VBA代码
Sub 删除含特定字符的单元格及空白单元格且下方单元格上移1()
Dim i As Long
Dim j As Long
Dim n As Long
n = 300
For i = n To 1 Step -1
For j = 1 To 5
If Cells(i, j) Like '=' Or Cells(i, j) = '$' Or _
Cells(i, j) = '' Or Cells(i, j) Like '(new)*' Then
Cells(i, j).Delete xlShiftUp
End If
Next j
Next i
End Sub
Sub 删除含特定字符的单元格及空白单元格且下方单元格上移2()
Dim i As Long
Dim j As Long
Dim n As Long
n = 300
For i = n To 1 Step -1
For j = 1 To 5
Do Until Cells(i, j).Find('▼*') Is Nothing
Cells(i, j).Find('▼*').Delete xlShiftUp
Loop
Next j
Next i
End Sub
Sub 删除含特定字符的单元格及空白单元格且下方单元格上移3()
Dim i As Long
Dim j As Long
Dim n As Long
n = 300
For i = n To 1 Step -1
For j = 1 To 5
Do Until Cells(i, j).Find('▲*') Is Nothing
Cells(i, j).Find('▲*').Delete xlShiftUp
Loop
Next j
Next i
End Sub

我的更多文章

下载客户端阅读体验更佳

APP专享