Board logo

標題: [發問] 請求函數 [打印本頁]

作者: mhl9mhl9    時間: 2014-11-21 01:04     標題: 請求函數

dim A as string
A="A1,A10:A20,A40:A50....X1,D2:F15,...."
因為len(A)>255,所以set R=range(A)失敗
請求方法把A斬開(A是","連接的字串),得到結果R=union(R1,R2,...Rn)
儲存格參照字串最長是"XFD1048576:XFD1048576"共21個字符,255/21=12
B=split(A,",",12),得到2個字串(把B(0)到B(10)用","串起來)和A(11)
但len(A(11))又大於255接下來如何處理呢?想不出方法,請師父幫忙,謝謝了
作者: mhl9mhl9    時間: 2014-11-21 01:34

dim A as string
A="A1,A10:A20,A40:A50....X1,D2:F15,...."
因為len(A)>255,所以set R=range(A)失敗
請 ...
mhl9mhl9 發表於 2014-11-21 01:04


我有方法了
Sub test()
Dim E As String
Dim R As Range

E= "$A$7:$P$10,$A$15:$P$18,$A$22:$P$25,$A$50:$P$73,$A$106:$P$145,$A$174:$P$201,$A$218:$P$249,$A$262:$P$273,$A$280:$P$281,$A$288:$P$289,$A$296:$P$305,$A$308:$P$313,$A$322:$P$337,$A$343:$P$346,$A$351:$P$354,$A$358:$P$361,$A$386:$P$409,$A$442:$P$481,$A$510:$P$537"
For Each i In Split(E, ",")
    If R Is Nothing Then
        Set R = Range(i)
    Else
        Set R = Union(R, Range(i))
    End If
Next i
        
R.Select   
End Sub




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)