0
我试图把用户输入和更新范围的基础上,一个表,但被陷在询问IM用户在与任何预定义条目不匹配的情况下“重新输入”他的输入。
下面是我的代码
Sub testing_input_in_formula()
Dim wbk1 As Workbook
Dim strName As String
test1 = "C:\Users\hayekn\Desktop\book1.xlsx"
Set wbk1 = Workbooks.Open(test1)
With wbk1.Sheets("Sheet1")
On Error Resume Next
Application.DisplayAlerts = True
strName = InputBox(Prompt:="Enter the week you would like to update", _
Title:="Week Selection.", Default:="Week 1")
If strName = "Your Name here" Or _
strName = vbNullString Then
Exit Sub
Else
Select Case strName
Case "Week 1"
.Range("A10") = "Week 1"
Case "Week 2"
.Range("B10") = "Week 2"
Case Else
MsgBox "Incorrect Entry."
'I want it here to loop back to the "Select Case strName",
'where user is prompted to re-enter the text
End Select
End If
End With
End Sub
真棒!像一个魅力工作:)并感谢您的改善。我是初学者,不知道如何使用最佳实践。再次感谢 !! – Nadz
不用担心,社区在这里帮助:) – Noldor130884