、同時按Alt+F11進入宏介面,點選單的插入,模組,貼上如下程式碼:
Sub Auto()
Dim iAreaCount As Integer
Dim R, C, I As Integer
iAreaCount = Selection.Areas.Count
If iAreaCount
For R = Selection.Row To Selection.Row + Selection.Rows.Count - 1
For C = Selection.Column To Selection.Column + Selection.Columns.Count - 1
If Cells(R, C) = "" Then Cells(R, C).FormulaR1C1 = "-"
Next C
Next R
Else
For I = 1 To iAreaCount
For R = Selection.Areas(I).Row To Selection.Areas(I).Row + Selection.Areas(I).Rows.Count - 1
For C = Selection.Areas(I).Column To Selection.Areas(I).Column + Selection.Areas(I).Columns.Count - 1
Next I
End If
End Sub
2、選擇你要寫入“-”的區域(可以包括非空白的區域,也可以按Ctrl同時選多個區域)
3、執行宏中的Auto就可以了
、同時按Alt+F11進入宏介面,點選單的插入,模組,貼上如下程式碼:
Sub Auto()
Dim iAreaCount As Integer
Dim R, C, I As Integer
iAreaCount = Selection.Areas.Count
If iAreaCount
For R = Selection.Row To Selection.Row + Selection.Rows.Count - 1
For C = Selection.Column To Selection.Column + Selection.Columns.Count - 1
If Cells(R, C) = "" Then Cells(R, C).FormulaR1C1 = "-"
Next C
Next R
Else
For I = 1 To iAreaCount
For R = Selection.Areas(I).Row To Selection.Areas(I).Row + Selection.Areas(I).Rows.Count - 1
For C = Selection.Areas(I).Column To Selection.Areas(I).Column + Selection.Areas(I).Columns.Count - 1
If Cells(R, C) = "" Then Cells(R, C).FormulaR1C1 = "-"
Next C
Next R
Next I
End If
End Sub
2、選擇你要寫入“-”的區域(可以包括非空白的區域,也可以按Ctrl同時選多個區域)
3、執行宏中的Auto就可以了