![]() |
Code Does not Realise equal values
Hi there The problem with this line : the code does realise that TextBox2.Value realy equal ws.Range("A65536").End(xlUp).Value.......why is that ?? any idea Code: -------------------- If TextBox2.Value = ws.Range("A65536").End(xlUp).Value Then ws.Cells(r, Exp) = TextBox1.Value -------------------- Code: -------------------- Private Sub CommandButton1_Click() Dim r As Long, Exp As Long Dim ws As Worksheet Set ws = Worksheets("sheet1") r = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row '*Exp Name Exp = ThisWorkbook.Sheets(1).Cells.Find(what:=TextBox1.V alue, _ LookIn:=xlValues, LookAt:=xlPart, _ SearchOrder:=xlByColumns, SearchDirection:=xlNext).Column If TextBox2.Value = ws.Range("A65536").End(xlUp).Value Then ws.Cells(r, Exp) = TextBox1.Value Else With ws .Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = TextBox2.Value .Cells(r, Exp) = TextBox1.Value End With End If End Sub -------------------- -- helmekki ------------------------------------------------------------------------ helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939 View this thread: http://www.excelforum.com/showthread...hreadid=487072 |
Code Does not Realise equal values
Hello Hesham, If the Value returned from the cell is not a String, the comparison will fail. The TextBox2.Value is always a string. The Cell value is variant and can be something else. Be sure the data you are comapring is of the same type. Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=487072 |
Code Does not Realise equal values
Thank u Ross 4 your reply The problem is solved Code: -------------------- If Val(TextBox2.Text) = ws.Range("A65536").End(xlUp).Value Then ws.Cells(r - 1, Exp) = TextBox1.Value -------------------- -- helmekki ------------------------------------------------------------------------ helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939 View this thread: http://www.excelforum.com/showthread...hreadid=487072 |
All times are GMT +1. The time now is 04:53 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com