Dear All,
i need a problem with an excel file where I use an userform with a date in a textbox which is always the date of today.
I would like to insert data from the userform only in the row which value in column C (a date) is correspondant to the date of the textbox in the Userform. I want that the user everyday with the userform can insert data only in the row correspondant to the date of today.
Here is my code:
i don't know the code to add.
just to explain:
1. The textbox with date is DateTextBox and the data to insert start in the excel fil is from the column D at row 4
2. I would like to insert data in the specific row in the sheet (column c which is a date starting from row 4) which value is equal to the DataTextBox
Really appreciate your help
Best
i need a problem with an excel file where I use an userform with a date in a textbox which is always the date of today.
I would like to insert data from the userform only in the row which value in column C (a date) is correspondant to the date of the textbox in the Userform. I want that the user everyday with the userform can insert data only in the row correspondant to the date of today.
Here is my code:
Code:
Private Sub OKButton_Click()
Dim emptyRow As Long
ActiveSheet.Activate
If NSTextBox.Value = "" Or _
TRXTextBox.Value = "" Or _
SalesTextBox.Value = "" Or _
TRTextBox.Value = "" Or _
LGTextBox.Value = "" Or _
PEEKTextBox.Value = "" Or _
SLGTextBox.Value = "" Or _
ACCTextBox.Value = "" Or _
ShoesTextBox.Value = "" Or _
RTWTextBox.Value = "" Or _
FURTextBox.Value = "" Or _
MANTextBox.Value = "" Or _
HTTextBox.Value = "" Then
Call MsgBox(Prompt:="All fields are mandatory!", _
Buttons:=vbCritical, _
Title:="Not filled!")
Else
Call inserimento
MsgBox "Form filled succesfully!", vbQuestion
End If
End Sub
Sub inserimento()
ActiveSheet.Activate
Dim emptyRow As Long
emptyRow = WorksheetFunction.CountA(Range("D:D")) + 2
Cells(emptyRow, 4).Value = NSTextBox.Value
Cells(emptyRow, 5).Value = TRXTextBox.Value
Cells(emptyRow, 6).Value = SalesTextBox.Value
Cells(emptyRow, 8).Value = TRTextBox.Value
Cells(emptyRow, 9).Value = LGTextBox.Value
Cells(emptyRow, 10).Value = PEEKTextBox.Value
Cells(emptyRow, 11).Value = SLGTextBox.Value
Cells(emptyRow, 12).Value = ACCTextBox.Value
Cells(emptyRow, 13).Value = ShoesTextBox.Value
Cells(emptyRow, 14).Value = RTWTextBox.Value
Cells(emptyRow, 15).Value = FURTextBox.Value
Cells(emptyRow, 16).Value = MANTextBox.Value
Cells(emptyRow, 17).Value = HTTextBox.Value
End Sub
i don't know the code to add.
just to explain:
1. The textbox with date is DateTextBox and the data to insert start in the excel fil is from the column D at row 4
2. I would like to insert data in the specific row in the sheet (column c which is a date starting from row 4) which value is equal to the DataTextBox
Really appreciate your help
Best