View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
PedroPastre PedroPastre is offline
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.