標題:
再問資料驗證
[打印本頁]
作者:
modelcrazyer
時間:
2012-10-15 23:49
標題:
有關資料驗證的問題
附件是我的表單和程式,想請教各位達人
我該怎麼修改才能讓我的A列中的數字
不會因為我的滑鼠到處亂點,而一直增加上去
作者:
GBKEE
時間:
2012-10-16 07:39
回復
1#
modelcrazyer
不會因為我的滑鼠到處亂點,而一直增加上去
那你希望在何條件下執行 Sub Worksheet_SelectionChange
作者:
modelcrazyer
時間:
2012-10-16 22:03
謝謝!!我已經解決了!!
作者:
modelcrazyer
時間:
2012-10-19 00:24
標題:
再問資料驗證
各位達人:
以下是我的資料驗證程式
S = Worksheets("工作表2").Cells(Rows.Count, "a").End(xlUp).Row
Num3 = Worksheets("工作表1").Cells(Rows.Count, "a").End(xlUp).Row
With Worksheets("工作表2").Range("A" & S + 1).Validation
.Delete
.Add Type:=xlValidateList, Operator:= _
xlBetween, Formula1:="=工作表1!$A$2:$A$" & Num3
.IgnoreBlank = Fsale
.InCellDropdown = True
.ShowInput = True
.ShowError = True
End With
我有個天馬行空的想法不知道能不能辦到,就是當我點選了某個A欄的資料驗證後
該儲存格就不會出現下拉選單,但是當我用delete把該儲存格的資料清除後
又能再出現資料驗證的下拉選單,這樣的想法有沒有可能辦到
作者:
GBKEE
時間:
2012-10-19 08:10
回復
4#
modelcrazyer
這工作表的程式碼
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Ex Target(1)
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Ex Target(1)
End Sub
Sub Ex(xlTarget As Range)
On Error Resume Next
'設定當一個執行階段錯誤產生時,程式控制立刻到發生錯誤陳述式接下去的陳述式,而繼續執行下去
If xlTarget.Column = 1 Then 'A欄
With xlTarget
If .Value <> "" Then
.Validation.InCellDropdown = False '沒有資料驗證會有錯誤
Else
.Validation.InCellDropdown = True '沒有資料驗證會有錯誤
End If
End With
End If
End Sub
複製代碼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)