728x90
반응형
A 파일 UserForm1의 TextBox1내용을 B파일 UserForm1의 TextBox1에 값을 전달하도록 해보겠습니다.
또 그 반대로 전송해 보도록 하겠습니다.
우선 A, B 파일 모두 모듈을 하나씩 추가해주고 아래와 같이 매소드를 작성합니다.
Sub FormShow(Optional value As String = "")
If Len(value) Then UserForm1.TextBox1.Text = value
If UserForm1.Visible Then Exit Sub
UserForm1.Show
End Sub
그리고 각각 폼의 CommandButton1의 클릭 이벤트를 아래와 같이 작성합니다.
A 파일의 UserForm1:)
Private Sub CommandButton1_Click()
Dim fPath As String
fPath = ThisWorkbook.Path & "\B.xlsm"
Application.Run "'" & fPath & "'!FormShow", TextBox1.Text
End Sub
B 파일의 UserForm1:)
Private Sub CommandButton1_Click()
Dim fPath As String
fPath = ThisWorkbook.Path & "\A.xlsm"
Application.Run "'" & fPath & "'!FormShow", TextBox1.Text
End Sub
이제 끝났습니다.

반응형
댓글