케이스 선택과 msgbox를 포함하는 구문을 작성했습니다. 구문을 사용하여 스프레드 시트에서 첫 번째 활성 셀을 찾고 일부 사전 정의 된 질문과 대답에 따라 A1 또는 A2로 이동 시키지만 명령이 최적으로 작동하지 않습니다. somene는 나를 도울 수 있습니까?케이스 선택 구문이 루프를 만들고 있습니다. 원하지 않습니다.
이전 질문에 제공된 답을 토대로 직관적으로 메시지 상자를 표시하고 싶지만 메시지 상자가 복잡해지기 쉽다.
아래 코드를 첨부했습니다.
Public Sub SurvAnalysis()
Dim InpSh As Worksheet
Dim fCell As Range
Dim msg1 As String, msg2 As String
Dim Ans1 As Variant, Ans2 As Variant
Set InpSh = ThisWorkbook.Worksheets("Input")
msg1 = "Are these headers included in the Data, and is the data in the correct format? { Dob ∏ StartDate ∏ End Date }"
Ans1 = MsgBox(msg1, vbYesNoCancel, " Data type")
Select Case Ans1
Case vbYes
On Error Resume Next
Set fCell = InpSh.Cells.Find(What:="*", _
After:=InpSh.Cells(Rows.Count, Columns.Count), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
On Error GoTo 0
If fCell Is Nothing Then
MsgBox "All cells are blank."
Else
fCell.CurrentRegion.Cut Destination:=InpSh.Range("A1")
End If
GoTo Quit:
Case vbCancel
MsgBox ("Get your data sorted out")
GoTo Quit:
Case vbNo
GoTo Option2:
End Select
Quit:
Option2:
msg2 = "Are the data in the correct manner and do you wish for us to include the headers on your behalf?"
Ans = MsgBox(msg2, vbYesNo, "Sort Data")
Select Case Ans
Case vbYes
Set fCell = InpSh.Cells.Find(What:="*", _
After:=InpSh.Cells(Rows.Count, Columns.Count), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If fCell Is Nothing Then
MsgBox "All cells are blank."
Else
fCell.CurrentRegion.Cut Destination:=InpSh.Range("A2")
InpSh.Range("A1").Value = " Dob"
InpSh.Range("B1").Value = " StartDate"
InpSh.Range("C1").Value = " End Date"
End If
Case vbNo
MsgBox ("Get your data sorted out")
GoTo Quit:
End Select
End Sub
읽어보십시오. [왜 누군가가 나를 도울 수 있습니까? 실제 질문이 아닙니까?] (https://meta.stackoverflow.com/questions/284236/why-is-can-someone-help-me-not) -an- 실제 - 질문) –
나는 그 질문이 합리적이라고 생각한다. 영업 담당자는 자신이 가진 문제를 분명히 밝히고 이유를 알 수 없습니다. –
감사합니다 R.Roe. 나는 내가 성취하려는 것을 알아내는 방법을 알지 못하고 프로그래밍 페이지에서 모든 철학적 인 질문을하는 것이 사소한 데이비드라고 생각하기 때문에 질문을하고있다. –