所以我做了一個簡單的用戶形式,將讓人們能夠輕鬆登出設備。我想這樣做,如果「設備」欄中的內容出來了,它會在「輸入/輸出」欄中說出來。但如果設備顯示「筆記本電腦1」和最後「日期&時間」列是空的,那麼它將在「IN/OUT」列中的筆記本電腦1旁邊說出。設備列在設備選項之間多選了一個「,」。
我不知道從哪裏開始。到目前爲止,我所做的工作是減去用戶表單條目的列表框和下拉菜單。
Private Sub cmdout_Click()
Set ws = ThisWorkbook.Worksheets("SignOut")
Dim sh As Worksheet
Dim LastRow As Long
Dim i As Integer
For i = 0 To equip.ListCount - 1
If equip.Selected(i) Then
Msg = Msg & equip.List(i) & ", "
End If
Next i
Msg = Left(Msg, Len(Msg) - 2)
Dim rngFound As Range
Dim strFirst As String
Dim strID As String
Dim strDay As String
Dim taken As Integer
strID = gov.Value
strDay = ""
Set rngFound = Columns("C").Find(strID, Cells(Rows.Count, "C"), xlValues, xlWhole)
If Not rngFound Is Nothing Then
strFirst = rngFound.Address
Do
If LCase(Cells(rngFound.Row, "G").Text) = LCase(strDay) Then
MsgBox "GOV is still signed out."
taken = 1
End If
Set rngFound = Columns("C").Find(strID, rngFound, xlValues, xlWhole)
Loop While rngFound.Address <> strFirst
End If
If taken = 0 Then
Application.Worksheets("SignOut").Range("A" & Rows.Count).End(xlUp).Offset(1).Value = Now()
Application.Worksheets("SignOut").Range("B" & Rows.Count).End(xlUp).Offset(1).Value = techname.Value
Application.Worksheets("SignOut").Range("C" & Rows.Count).End(xlUp).Offset(1).Value = gov.Value
Application.Worksheets("SignOut").Range("D" & Rows.Count).End(xlUp).Offset(1).Value = Msg
Application.Worksheets("SignOut").Range("E" & Rows.Count).End(xlUp).Offset(1).Value = otherequip.Value
End If
Set rngFound = Nothing
End Sub
登錄形式:
Private Sub CommandButton1_Click()
Dim rngFound As Range
Dim strFirst As String
Dim strID As String
Dim strDay As String
strID = techname1.Value
strDay = ""
Set rngFound = Columns("B").Find(strID, Cells(Rows.Count, "B"), xlValues, xlWhole)
If Not rngFound Is Nothing Then
strFirst = rngFound.Address
Do
Application.Worksheets("SignOut").Cells(rngFound.Row, "G").Value = Now()
Set rngFound = Columns("B").Find(strID, rngFound, xlValues, xlWhole)
Loop While rngFound.Address <> strFirst
End If
Set rngFound = Nothing
End Sub
歡迎來到Stack Overflow。 SO不是我網站或教學網站的代碼,有許多網站可以幫助您理解基礎知識。 SO是社區將幫助解決現有代碼中特定問題的地方。如果您有現有的代碼,請將其放在原始帖子中。 –