您可以使用 Worksheet Change 事件触发某些范围的自动更新。这要求用户部分输入所需的输入(他们需要退出单元格才能触发)并将自动填充剩余部分。例如:
Public boolChanging As Boolean
Private Sub Worksheet_Change(ByVal rng As Range)
Dim strAutoFinish As String, iStartPos As Integer
'Exit unless updates occur when and where you want
If boolChanging Or rng.Row < 1 Or rng.Column <> 1 Or rng.Columns.Count > 1 Or rng.Rows.Count > 1 Then Exit Sub
If rng = "" Then Exit Sub 'This needs to be here in case multiple cells are editted
boolChanging = True
strAutoFinish = ";DA20;Diamond;CJ3;Citation;..."
iStartPos = InStr(UCase(strAutoFinish), ";" & UCase(rng))
If iStartPos > 0 Then
rng = Mid(strAutoFinish, iStartPos + 1, InStr(iStartPos + 1, strAutoFinish, ";") - iStartPos - 1)
Else 'Leave this part if you want it to delete invalid entries
rng = ""
End If
boolChanging = False
End Sub