Hi,
I have the following code in my workbook, and when I select the date in the calendar in the Taxinvoice userform from command button 2 it is returning the value to both the textbox D8 on the Taxinvoice userform and also to cell A1 on the active worksheet.
Can anyone please explain how I modify this code to only make the value return to the D8 text box on the userform.
I have tried deleting the reference to A1 but then it doesn’t work at all.
Thanks!
I have the following code in my workbook, and when I select the date in the calendar in the Taxinvoice userform from command button 2 it is returning the value to both the textbox D8 on the Taxinvoice userform and also to cell A1 on the active worksheet.
Can anyone please explain how I modify this code to only make the value return to the D8 text box on the userform.
I have tried deleting the reference to A1 but then it doesn’t work at all.
Thanks!
Code:
[B]Userform1[/B]
Option Explicit
'UserForm with Frame1
Private WithEvents Calendar1 As cCalendar
Private Sub Calendar1_DblClick()
ActiveCell.Value = Calendar1.Value
Unload Me
End Sub
[B]Module 1[/B]
Sub lancia_cCalendar()
Dim strCell As String
strCell = ActiveCell.Address
Range("A1").Select
UserForm1.Show
Range(strCell).Select
End Sub
[B]TaxInvoice Userform[/B]
Private Sub CommandButton2_Click()
Call lancia_cCalendar
Me.D8.Text = Sheet1.Cells(1, 1).Value
End Sub
Private Sub D8_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Dim bRet As Boolean
Cancel = False
If IsDate(Me.D8.Text) Then
Me.D8.Text = CStr(DateValue(Me.D8.Text))
Else
If Len(Me.D8.Text) > 0 Then
Cancel = True
bRet = MsgBox("Not a valid date", vbCritical, "Date Entry Error")
End If
End If
End Sub