想請教大大們為何會失敗呢~?
'自訂區域
With Sheets("轉換表")
myRange = .Range("s2:s" & .Range("s65536").End(xlUp).Row) '資料驗證用
end With
'資料驗證選單
'試過兩種方式
'第一種
For Each e In myRange
arr = arr & "," & e
Next
arr = Split(Mid(arr, 2, 10000), ",")
With Range("d2:d" & allr).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=arr
End With
'第二種是直接將Arr換成myRange作者: PKKO 時間: 2015-1-6 20:34
您上面的程式就綠色的那行有問題.變成註解就可以執行
Public Sub AAAAAA()
With Me
cc = .Rows(1).Find("所有單位", Lookat:=xlWhole).Column '代號的Column
Set myRange = .Range("A2:A" & .Range("A65536").End(xlUp).Row) '資料驗證用
For Each e In myRange
ARR = ARR & "," & e
Next
MsgBox ARR
' ARR = Split(Mid(ARR, 2, 10000), ",") '看過陣列的值確定沒問題
With .Range("d2:d10").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=ARR
End With
End With
End Sub作者: HUNGCHILIN 時間: 2015-3-2 00:10
本帖最後由 HUNGCHILIN 於 2015-3-2 00:11 編輯
With Me
CC = .Rows(1).Find("所有單位", Lookat:=xlWhole).Column '代號的Column