我提前为发布相同的问题道歉,但我不知道如何添加其他代码示例 . 如果有办法在上一个问题中添加其他代码,请提供建议 . 基本上,我试图将一些文本框值保存到我的工作表中,以便在关闭和重新打开userform时重新启动它们 . 这就是我到目前为止......但显然是错误的!
基本上,我有一个组合框(procNamecombobox),从工作表"DailyNumbers"上的"A"列填充 . 我只想让下面的textboxe.Values保存在每个名称旁边的相应列(B,C,D&E)中,当它在组合框中选中时 .
Private Sub procNamecombobox_Change()
Dim ws As Worksheet
Dim EmptyRow As Long
Set ws = Sheets("DailyNumbers")
EmptyRow = ws.Range("B" & Rows.Count).End(xlUp).Row + 1
' *** Check combobox selection ***
If procNamecombobox.ListIndex > -1 Then
ws.Range("B" & EmptyRow).Value = completeCount.Text
ws.Range("C" & EmptyRow).Value = handledCount.Text
ws.Range("D" & EmptyRow).Value = wipCount.Text
ws.Range("E" & EmptyRow).Value = suspendCount.Text
ws.Range("B2:B" & EmptyRow).Sort key1:=ws.Range("A1:A" & EmptyRow), order1:=xlAscending, Header:=xlNo
Else
MsgBox "Please select your name"
End If
End Sub
1 回答
如下所示,它将在列A中搜索Combobox值,如果发现它将更新该行,如果没有找到,它将填充EmptyRow: