我想从excel中的单元格中只删除空行。这里是我想要完成祖国:删除所选单元格中的空行
+-----------------+ +---------------------+ +---------------------+
| EXAMPLE DATA | | EXPLANATION | | EXPECTED RESULT |
+-----------------+ +---------------------+ +---------------------+
| cell1_text1 | | cell1_text1 | | cell1_text1 |
| cell1_text2 | | cell1_text2 | | cell1_text2 |
+-----------------+ +---------------------+ +---------------------+
| | | cell2_empty_line | | cell2_text1 |
| cell2_text1 | | cell2_text1 | +---------------------+
+-----------------+ +---------------------+ | cell3_text1 |
| cell3_text1 | | cell3_text1 | | cell3_text2 |
| | | cell3_emptyline | +---------------------+
| cell3_text2 | | cell3_text2 | | cell4_text1 |
+-----------------+ +---------------------+ +---------------------+
| | | cell4_emptyline | | cell5_text1 |
| | | cell4_emptyline | +---------------------+
| cell4_text1 | | cell4_text1 | | cell6_text1 |
+-----------------+ +---------------------+ | cell6_text2 |
| cell5_text1 | | cell5_text1 | | cell6_text3 |
+-----------------+ +---------------------+ | cell6_text4 |
| cell6_text1 | | cell6_text1 | +---------------------+
| cell6_text2 | | cell6_text2 |
| cell6_text3 | | cell6_text3 |
| | | cell6_emptyline |
| cell6_text4 | | cell6_text4 |
+-----------------+ +---------------------+
Sub RemoveCarriageReturns()
Dim MyRange As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each MyRange In ActiveSheet.UsedRange
If 0 < InStr(MyRange, Chr(10)) Then
MyRange = Replace(MyRange, Chr(10), "")
End If
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
,但它并没有给我想要的结果,它会删除所有小区中的所有特征线。
+---------------------------------------------+
| CURRENT SCRIPT RESULT |
+---------------------------------------------+
| cell1_text1cell1_text2 |
+---------------------------------------------+
| cell2_text1 |
+---------------------------------------------+
| cell3_text1cell3_text2 |
+---------------------------------------------+
| cell4_text1 |
+---------------------------------------------+
| cell5_text1 |
+---------------------------------------------+
| cell6_text1cell6_text2cell6_text3cell6_text4|
+---------------------------------------------+
如何测试,如果行不包含任何其他字母和细胞内只删除该行? 如何将该宏仅应用于当前选定的单元格?
你只有一个可以在两者之间移动数值-----------------行吗? – cboden