Option
Explicit
Private
mobjWorkbook
As
Workbook
Private
Sub
CommandButton1_Click()
If
mobjWorkbook
Is
Nothing
Then
Set
mobjWorkbook = Workbooks.Add
With
mobjWorkbook.ActiveSheet
.Cells(3, 1).Value = TextBox1.Value
.Cells(5, 4).Value = TextBox2.Value
.Cells(8, 7).Value = TextBox3.Value
.Cells(7, 1).Value = TextBox4.Value
End
With
End
Sub
Private
Sub
UserForm_Terminate()
Set
mobjWorkbook =
Nothing
End
Sub