Code Does not Realise equal values

hmk

Active Member
Joined
Jun 8, 2004
Messages
423
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.Value, _
                        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
 

hmk

Active Member
Joined
Jun 8, 2004
Messages
423
The problem is solved

Code:
If Val(TextBox2.Text) = ws.Range("A65536").End(xlUp).Value Then
ws.Cells(r - 1, Exp) = TextBox1.Value
 

Forum statistics

Threads
1,081,530
Messages
5,359,347
Members
400,524
Latest member
Excelbat

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top