![Excel, 구조화된 방식으로 셀에 더 많은 정보 추가](https://rvso.com/image/1543366/Excel%2C%20%EA%B5%AC%EC%A1%B0%ED%99%94%EB%90%9C%20%EB%B0%A9%EC%8B%9D%EC%9C%BC%EB%A1%9C%20%EC%85%80%EC%97%90%20%EB%8D%94%20%EB%A7%8E%EC%9D%80%20%EC%A0%95%EB%B3%B4%20%EC%B6%94%EA%B0%80.png)
답변1
결국에는 일부 텍스트 상자와 "데이터"라는 다른 시트의 동일한 열/행에 값을 저장하기 위한 버튼이 있는 사용자 양식을 만들었습니다.
이 같은:
Dim xml As String
xml = xml + "<CellDetails>"
xml = xml + " <Budget>" + UserForm1.txtBudget.Text + "</Budget>"
xml = xml + " <Comments>" + UserForm1.txtComments.Text + "</Comments>"
xml = xml + " <StartDate>" + Format(MonthView1.Value, "yyyy-mm-dd") + "</StartDate>"
xml = xml + " <EndDate>" + Format(MonthView2.Value, "yyyy-mm-dd") + "</EndDate>"
xml = xml + "</CellDetails>"
ThisWorkbook.Sheets("Data").Range(Selection.Address).Value = xml
그런 다음 셀을 "오른쪽 클릭"할 때 이벤트 리스너를 사용하여 시트에서 이를 트리거하고 양식 컨트롤에 값을 채웁니다.
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
오류 발생 시 다음 재개
' Ctrl 키를 누른 경우에만 이것을 트리거합니다 If IsControlKeyDown() = True Then
If Not ThisWorkbook.Sheets("Data").Range(Selection.Address).Value = "" Then
Dim XDoc As MSXML2.DOMDocument
Set XDoc = CreateObject("MSXML2.DOMDocument")
XDoc.LoadXML (ThisWorkbook.Sheets("Data").Range(Selection.Address).Value)
' Setting the form values
UserForm1.txtBudget.Text = XDoc.SelectSingleNode("//CellDetails/Budget").Text
UserForm1.txtComments.Text = XDoc.SelectSingleNode("//CellDetails/Comments").Text
' Setting the dates
UserForm1.MonthView1.Value = CDate(XDoc.SelectSingleNode("//CellDetails/StartDate").Text)
UserForm1.lbStartDate = XDoc.SelectSingleNode("//CellDetails/StartDate").Text
UserForm1.MonthView2.Value = CDate(XDoc.SelectSingleNode("//CellDetails/EndDate").Text)
UserForm1.lbEndDate = XDoc.SelectSingleNode("//CellDetails/EndDate").Text
End If
UserForm1.Show
Cancel = True
End If
On Error GoTo 0
서브 끝