Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Matches Stacey Excel Discussion (Misc queries) 1 February 20th 07 02:24 PM
Vlookup 2 data matches? Nav Excel Discussion (Misc queries) 5 November 27th 05 04:18 PM
TextBox1.value=TextBox2.value-(TextBox3.value+TextBox4.value) helmekki[_29_] Excel Programming 1 October 15th 04 04:15 AM
TextBox1.value=TextBox2.value-(TextBox3.value+TextBox4.value) helmekki[_27_] Excel Programming 2 October 15th 04 12:32 AM
TextBox1.value=TextBox2.value-(TextBox3.value+TextBox4.value) helmekki[_26_] Excel Programming 2 October 14th 04 05:23 AM


All times are GMT +1. The time now is 09:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"