ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   When data in TextBox2 matches data in TextBox1 (https://www.excelbanter.com/excel-programming/348568-when-data-textbox2-matches-data-textbox1.html)

Maddoktor

When data in TextBox2 matches data in TextBox1
 
Hi all,

I have developed a userform that when the user clicks the OK button, the
data entered is dumped onto Sheet2.

I would like for the data, once entered, that if the data into TextBox2 is
identical to the data entered into TextBox1, then all data should be dumped
onto Sheet1 instead.

What coding would I need to add to solve this problem.

Thanx in advance.



PedroPastre

When data in TextBox2 matches data in TextBox1
 

For this functionality you may use the code in the "OK" button of your
UserFOrm:

'================================================= =

if TextBox1.Value = TextBox2.Value then

lastrow= Worksheets("Sheet1").Range("A65536").End(xlUp).Row

Worksheets("Sheet1").Range("A" & lastrow).Value = TextBox1.Value
Worksheets("Sheet1").Range("B" & lastrow).Value = TextBox2.Value
'...and so on....

elseif TextBox1.Value < TextBox2.Value then

lastrow= Worksheets("Sheet2").Range("A65536").End(xlUp).Row

Worksheets("Sheet2").Range("A" & lastrow).Value = TextBox1.Value
Worksheets("Sheet2").Range("B" & lastrow).Value = TextBox2.Value
'...and so on....

end if

'=================================================

I hope this code can help you...

felll free to ask to me if you have any doubt OK?



"Maddoktor" wrote:

Hi all,

I have developed a userform that when the user clicks the OK button, the
data entered is dumped onto Sheet2.

I would like for the data, once entered, that if the data into TextBox2 is
identical to the data entered into TextBox1, then all data should be dumped
onto Sheet1 instead.

What coding would I need to add to solve this problem.

Thanx in advance.




Tom Ogilvy

When data in TextBox2 matches data in TextBox1
 
Dim sh as Worksheet
sh = Worksheets("Sheet2")
if Textbox2.Text = TextBox1.Text then
sh = Worksheets("Sheet1")
End if
' no use sh as your reference for writing your data.

--
Regards,
Tom Ogilvy

"Maddoktor" wrote in message
...
Hi all,

I have developed a userform that when the user clicks the OK button, the
data entered is dumped onto Sheet2.

I would like for the data, once entered, that if the data into TextBox2 is
identical to the data entered into TextBox1, then all data should be

dumped
onto Sheet1 instead.

What coding would I need to add to solve this problem.

Thanx in advance.





Maddoktor

When data in TextBox2 matches data in TextBox1
 
Hey Pedro,

This is the coding I have so far for the OK button. I am not sure where I
should put your code. As you can see, the data entered will fill each column
from B5 to E5 and then moves onto the next line and fills B6 to E6 ... etc.
The two worksheets I have are named "Late Delivery" and "On-Time Delivery".
If the data entered in txtSell in identical or prior to the data entered in
txtMade then the data is to be dumped into the worksheet "On-Time" else it
is to be dumped into worksheet "Late Delivery".

-----------------------------
Private Sub cmdOK_Click()

ActiveWorkbook.Sheets("Late Delivery").Activate
Range("B5").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtJobNo.Value
ActiveCell.Offset(0, 1) = txtJobNo.Value
ActiveCell.Offset(0, 2) = cboCustomer.Value
ActiveCell.Offset(0, 3) = txtMade.Value
ActiveCell.Offset(0, 3) = DateValue(Me.txtMade.Value)
ActiveCell.Offset(0, 4) = txtSell.Value
ActiveCell.Offset(0, 4) = DateValue(Me.txtSell.Value)
Range("A1").Select

End Sub
----------------------

Hope this helps with my problem.

Thanx



"PedroPastre" wrote in message
...

For this functionality you may use the code in the "OK" button of your
UserFOrm:

'================================================= =

if TextBox1.Value = TextBox2.Value then

lastrow= Worksheets("Sheet1").Range("A65536").End(xlUp).Row

Worksheets("Sheet1").Range("A" & lastrow).Value = TextBox1.Value
Worksheets("Sheet1").Range("B" & lastrow).Value = TextBox2.Value
'...and so on....

elseif TextBox1.Value < TextBox2.Value then

lastrow= Worksheets("Sheet2").Range("A65536").End(xlUp).Row

Worksheets("Sheet2").Range("A" & lastrow).Value = TextBox1.Value
Worksheets("Sheet2").Range("B" & lastrow).Value = TextBox2.Value
'...and so on....

end if

'=================================================

I hope this code can help you...

felll free to ask to me if you have any doubt OK?



"Maddoktor" wrote:

Hi all,

I have developed a userform that when the user clicks the OK button, the
data entered is dumped onto Sheet2.

I would like for the data, once entered, that if the data into TextBox2
is
identical to the data entered into TextBox1, then all data should be
dumped
onto Sheet1 instead.

What coding would I need to add to solve this problem.

Thanx in advance.







All times are GMT +1. The time now is 11:35 AM.

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