我想從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