ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   subtracting serial dates (https://www.excelbanter.com/excel-programming/383326-subtracting-serial-dates.html)

ll

subtracting serial dates
 
Hi,
I have calendar objects populating two text boxes in my Excel vba
form, with a third box to show the difference of the first two (I
subtract box 1 from box 2).
I am getting a mismatch error, however, and I was wondering if a
change in formatting would correct this? Thanks for any help you can
provide.
Kind Regards,
Louis
===
Here is my code for the form:

Private Sub TextBox1_Change()
End Sub

Private Sub TextBox2_Change()
Dim fillamt As Date
fillamt = UserForm1.TextBox2 - UserForm1.TextBox1
TextBox3 = fillamt
End Sub

Private Sub TextBox3_Change()
End Sub

Private Sub UserForm_Click()
End Sub


ll

subtracting serial dates
 
I need to add that I get the error when I begin entering a date value
into box 2 (non-date, numerical values work fine).
Thanks


On Feb 15, 11:05 am, "ll" wrote:
Hi,
I have calendar objects populating two text boxes in my Excel vba
form, with a third box to show the difference of the first two (I
subtract box 1 from box 2).
I am getting a mismatch error, however, and I was wondering if a
change in formatting would correct this? Thanks for any help you can
provide.
Kind Regards,
Louis
===
Here is my code for the form:

Private Sub TextBox1_Change()
End Sub

Private Sub TextBox2_Change()
Dim fillamt As Date
fillamt = UserForm1.TextBox2 - UserForm1.TextBox1
TextBox3 = fillamt
End Sub

Private Sub TextBox3_Change()
End Sub

Private Sub UserForm_Click()
End Sub




merjet

subtracting serial dates
 
Private Sub TextBox2_Change()
Dim dt1 As Date
Dim dt2 As Date
dt1 = TextBox1
dt2 = TextBox2
TextBox3 = dt2 - dt1
End Sub

Hth,
Merjet



Dave Peterson

subtracting serial dates
 
Private Sub TextBox2_Change()
Dim fillamt As Date
fillamt = Cdate(UserForm1.TextBox2) - cdate(UserForm1.TextBox1)
TextBox3 = format(fillamt, "mm/dd/yyyy")
End Sub


ll wrote:

Hi,
I have calendar objects populating two text boxes in my Excel vba
form, with a third box to show the difference of the first two (I
subtract box 1 from box 2).
I am getting a mismatch error, however, and I was wondering if a
change in formatting would correct this? Thanks for any help you can
provide.
Kind Regards,
Louis
===
Here is my code for the form:

Private Sub TextBox1_Change()
End Sub

Private Sub TextBox2_Change()
Dim fillamt As Date
fillamt = UserForm1.TextBox2 - UserForm1.TextBox1
TextBox3 = fillamt
End Sub

Private Sub TextBox3_Change()
End Sub

Private Sub UserForm_Click()
End Sub


--

Dave Peterson


All times are GMT +1. The time now is 08:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com