I am seeing some 1900 dates for my triggers as seen in the picture .For TDS1 input, this code is expected to take userinput from column E and add 6 weeks and store it in column F. Similarly, add 8 weeks and store it in column G. For SS1 input, this code is expected to take userinput from column E and add 18months and store it in column F and add 24 months and store in column F.
As seen in the picture, for row 2 (TDS1) I am seeing some 1900 dates and for row 3 (SS1) I am not seeing any dates for my triggers. Can anyone please spot any errors in my code or syntax.
Private Sub Cmd_Transfer_Click()
row = ActiveCell.row
MsgBox row
Cells(row, 1).Value = txt_BPName.Text
Cells(row, 2).Value = txt_SPName.Text
Cells(row, 3).Value = Loc_txtbox.Text
Cells(row, 4).Value = txt_Curr_Date.Text
Cells(row, 5).Value = Txt_Prod_Loc_Date.Text
Cells(row, 8).Value = Stn_Shelf_Num.Text
txt_BPName.Text = ""
txt_SPName.Text = ""
Loc_txtbox.Text = ""
txt_Curr_Date = ""
Txt_Prod_Loc_Date = ""
Stn_Shelf_Num.Text = ""
ActiveCell.Offset(1, 0).Select
End Sub
Private Sub Loc_txtbox_Change()
Dim Date1 As Date
Dim row As Integer
row = ActiveCell.row
Date1a = Cells(row, 5).Value
If Loc_txtbox.Text Like "TDS[0-9]*" Then
T1a = DateAdd("ww", 6, Date1a)
Cells(row, 6).Formula = T1a
T1b = DateAdd("ww", 8, Date1a)
Cells(row, 7).Formula = T1b
If Cells(row, 4).Value < Cells(row, 6).Value Then
Cells(row, 1).Interior.Color = vbGreen
ElseIf Cells(row, 4).Value >= Cells(row, 6).Value And Cells(row, 4).Value <= Cells(row, 7).Value Then
Cells(row, 1).Interior.Color = vbYellow
Else
Cells(row, 1).Interior.Color = vbRed
End If
Date1a = Cells(row, 5).Value
ElseIf Loc_txtbox.Text Like "SS[0-9]*" Then
T1c = DateAdd("M", 18, Date1a)
Cells(row, 6).Formula = T1a
T1d = DateAdd("M", 24, Date1a)
Cells(row, 7).Formula = T1b
If Cells(row, 4).Value < Cells(row, 6).Value Then
Cells(row, 1).Interior.Color = vbGreen
ElseIf Cells(row, 4).Value >= Cells(row, 6).Value And Cells(row, 4).Value <= Cells(row, 7).Value Then
Cells(row, 1).Interior.Color = vbYellow
Else
Cells(row, 1).Interior.Color = vbRed
End If
End If
End Sub
Private Sub txt_BPName_Change()
Dim i As Long
Dim Count As Long
Do
For i = 1 To Len(txt_BPName.Text)
Select Case Asc(Mid(txt_BPName.Text, i, 1))
Case 45, 48 To 57, 65 To 90, 97 To 122
'Cells(Row, 1).Select
ActiveCell.Formula = txt_BPName.Text
Count = 0
Case Else
MsgBox ("Invalid Entry")
Exit For
txt_BPName.SetFocus
Count = 1
End Select
Next
Loop While Count <> 0
End Sub
Private Sub txt_SPName_Change()
Dim j As Long
Dim Count1 As Long
Do
For j = 1 To Len(txt_SPName.Text)
Select Case Asc(Mid(txt_SPName.Text, j, 1))
Case 45, 48 To 57, 65 To 90, 97 To 122
'Cells(Row, 1).Select
ActiveCell.Formula = txt_SPName.Text
Count1 = 0
Case Else
MsgBox ("Invalid Entry")
Exit For
txt_SPName.SetFocus
Count1 = 1
End Select
Next
Loop While Count1 <> 0
End Sub
Private Sub txt_Curr_Date_Change()
TodaysDate = Now()
txt_Curr_Date.Value = Format(TodaysDate, "mm/dd/yyyy")
End Sub
Private Sub Txt_Prod_Loc_Date_Change()
End Sub
Private Sub Stn_Shelf_Num_Change()
Dim k As Long
Dim Count2 As Long
Do
For k = 1 To Len(Stn_Shelf_Num.Text)
Select Case Asc(Mid(Stn_Shelf_Num, k, 1))
Case 48 To 57
ActiveCell.Formula = Stn_Shelf_Num.Text
Count2 = 0
Case Else
MsgBox ("Invalid Entry")
Exit For
Stn_Shelf_Num.SetFocus
Count2 = 1
End Select
Next
Loop While Count2 <> 0
End Sub
Private Sub UserForm_Click()
End Sub
