If mStr1a = "在職" Then
OptionButton1.Value = True
ElseIf mStr1a = "離職" Then
OptionButton2.Value = True
End If
mRng1a.Offset(, -1).Select
End If
End With
Set mSht1 = Nothing
Set mRng1 = Nothing
Set mRng1a = Nothing
End Sub
感恩大大!作者: GBKEE 時間: 2010-10-18 08:58
本帖最後由 GBKEE 於 2010-10-18 09:01 編輯
回復 1#dechiuan999
問題在Private Sub CommandButton5_Click()
With Range("員工基本資料")
mStr1a = TextBox1.Text
Set mRng1b = Range("員工基本資料").Columns(1).Find(what:=mStr1a, lookat:=xlWhole, searchorder:=xlByRows)
If Not mRng1b Is Nothing Then
MsgBox "你輸入的員工編號重覆" & vbCrLf & vbCrLf & "請重新輸入員工編號"
Exit Sub
End If
mRow1 = Range("員工基本資料").Rows.Count '計算出定義名稱的列數
If TypeName(Selection) = "Range" Then
.Cells(1).End(xlDown).Offset(1).Select '請加入這一段
If Intersect(Selection, Range("員工基本資料").End(xlDown).Offset(1)) Is Nothing Then
'MsgBox "請先選取輸入資料指定位置"
Exit Sub
Else
''''''''''''''''''''''''''''''''''''''''''''''''''''''
CommandButton5_Click() 新增資料的防呆措施 少了姓名的防呆
防呆之後 新增資料直接用 不用理會selection的事 如下
Private Sub CommandButton5_Click()
Dim Sh As Worksheet, Rng As Range
Set Sh = Worksheets("員工基本資料")
Set Rng = Sh.Range("A" & Rows.Count).End(xlUp).Offset(1)
With TextBox1
If Application.CountIf(Sh.Columns(1), .Text) > 0 Then