|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 Vicel 于 2014-11-26 11:04 编辑
gaoch35 发表于 2014-11-26 09:35
如果把空格符除外,怎么改,即一个单元格中只有空格符就不算
看代码For Each a In Range(C1 & "1:" & C1 & Range(C1 & Rs).End(xlUp).Row).Cells
b = a.Value
a.Value = IIf(Trim(b) = "", "", b)
Next
判断一个单元格如果只含空格符就清空
- Sub PX()
- C = 6 '即F列
- Columns(C).Insert Shift:=xlToRight
- C1 = Chr(C + 65)
- C0 = Chr(C + 64)
- i = 1
- Rs = Rows.Count
- For Each a In Range(C1 & "1:" & C1 & Range(C1 & Rs).End(xlUp).Row).Cells
- b = a.Value
- a.Value = IIf(Trim(b) = "", "", b)
- Next
- Do
- If Cells(i, C + 1) <> "" Then
- n = i
- Else
- n = Range(C1 & i).End(xlDown).Row
- End If
- If n = Rs Then
- Range(C0 & n) = 1
- GoTo 1
- End If
- s = Range(C1 & n & ":" & C1 & Rs).Find("", , , , 1).Row
- arr = Range(C1 & n & ":" & C1 & s)
- If s - n = 1 Then
- Range(C1 & n).Resize(UBound(arr), 1) = ""
- GoTo 2
- End If
- Range(C0 & n).Resize(UBound(arr), 1) = s - n
- 2: i = s + 1
- Loop Until i > Range(C1 & Rs).End(xlUp).Row
- 1: Range(C0 & ":" & C1).Sort Key1:=Range(C0 & 1), Order1:=xlAscending, Header:=xlNo, _
- OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
- :=xlPinYin, DataOption1:=xlSortNormal
- Columns(C0).Delete Shift:=xlToLeft
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|