返回列表 上一主題 發帖

[分享] 分享

[分享] 分享

以下Test,執行一次,activesheet英文全部改為"大楷,再執行一次英文全部改為"小楷"
Sub LUcase(A As Boolean)
Dim R As Range
Dim R1 As Range
Dim R2 As Range
Dim cell As Range
Dim cell1 As Range

For Each cell In ActiveSheet.UsedRange.Areas
    Set R1 = cell.Resize(, 1)
    Set R2 = cell.Resize(1)
    If A = True Then
        cell = Evaluate("IF(ROW(" & R1.Address & "),iF(COLUMN(" & _
            R2.Address & "),upper(" & cell.Address & ")))")
    Else
        cell = Evaluate("IF(ROW(" & R1.Address & "),iF(COLUMN(" & _
            R2.Address & "),lower(" & cell.Address & ")))")
    End If
Next cell
End Sub

Sub test()
Static A As Boolean
LUcase A
A = Not A
End Sub
lmh

回復 1# mhl9mhl9
簡化一下
  1. Option Explicit
  2. Sub Ex()
  3.      Dim E As Range
  4.      Static A As Boolean
  5.      For Each E In ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants)
  6.         E = IIf(A, UCase(E), LCase(E))
  7.      Next
  8.      A = Not A
  9. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

GBKEE,謝謝提供簡易方法,很好用,但usedrange很大時很慢(我的個案110000行資料),還是謝謝
lmh

TOP

        靜思自在 : 有多少力量就做多少事,不要心存等待,等待才會落空。
返回列表 上一主題