Home > Software engineering >  Excel VBA form the content of the text box input how to automatically saved to the workbook
Excel VBA form the content of the text box input how to automatically saved to the workbook

Time:05-26

As shown in figure A VBA form within A, B, C, D, E, F input characters in the text box, then click the check automatically when the inside of the content of the input automatically saved to the figure 2 workbook corresponding column, and automatic generation of input time, if not fill in the content, including any column indicates that check failure, whereas prompt check is successful,

CodePudding user response:

 

The Public Function checks () As a Boolean
Dim strA As String, strB As String, strC As String
Red:
'StrA=Trim (txtA. Text)
StrB=Left $(Trim (txtF. Text), Len (strA))
StrC=Mid (Trim (txtC. Text), Len (Trim (txtD. Text)) + 2, Len (strA))
Checks=strA=strB And strA strC=
If checks=False Then
The Exit Function
End the If

Blue:
'StrA=Trim (txtD. Text)
StrB=Trim (txtE. Text)
StrC=Mid (Trim (txtC. Text), 1, Len (strA))
Checks=strA=strB And strA strC=

End the Function


Private Function insToXls () As a Boolean
Dim index As an Integer, inx As Integer
Index=Cells (Rows) Count, 1.) the End (xlUp). At the End of the row 'find lines
Inx=Val (Range (" A "& amp; The index)) + 1 'at the end of the line number + 1

Dim arr As the Variant
Arr=Array (inx txtA. Text, txtB. Text, txtC. Text, txtD. Text, txtE. Text, txtF. Text, Now ())
Range (" A "& amp; The index + 1, "H" & amp; The index + 1)=arr

End the Function

Private Sub cmd_Click ()
If checks () Then
MsgBox "success!" VbOKOnly, "than the results
"InsToXls
The Else
MsgBox "than failure!" VbOKOnly, "than the results
"End the If

End Sub




CodePudding user response:

The
reference 1/f, rogue response:
 

The Public Function checks () As a Boolean
Dim strA As String, strB As String, strC As String
Red:
'StrA=Trim (txtA. Text)
StrB=Left $(Trim (txtF. Text), Len (strA))
StrC=Mid (Trim (txtC. Text), Len (Trim (txtD. Text)) + 2, Len (strA))
Checks=strA=strB And strA strC=
If checks=False Then
The Exit Function
End the If

Blue:
'StrA=Trim (txtD. Text)
StrB=Trim (txtE. Text)
StrC=Mid (Trim (txtC. Text), 1, Len (strA))
Checks=strA=strB And strA strC=

End the Function


Private Function insToXls () As a Boolean
Dim index As an Integer, inx As Integer
Index=Cells (Rows) Count, 1.) the End (xlUp). At the End of the row 'find lines
Inx=Val (Range (" A "& amp; The index)) + 1 'at the end of the line number + 1

Dim arr As the Variant
Arr=Array (inx txtA. Text, txtB. Text, txtC. Text, txtD. Text, txtE. Text, txtF. Text, Now ())
Range (" A "& amp; The index + 1, "H" & amp; The index + 1)=arr

End the Function

Private Sub cmd_Click ()
If checks () Then
MsgBox "success!" VbOKOnly, "than the results
"InsToXls
The Else
MsgBox "than failure!" VbOKOnly, "than the results
"End the If

End Sub




[face] emoji: 010 PNG [/face] back to the wrong post!
  •  Tags:  
  • VBA
  • Related