From: Philosophaie on
I am working in Sheet2. The data is in Sheet1. I can not get the data in
column in the 15th column to initalize the "If" even if Textbox1.Text matches.

For k= 1 to 100
If Sheets("Sheet1").Cells(k,15)=TextBox1.Text Then
code...
End if
Next k
From: Philosophaie on
I tried:

If Sheets("Sheet1").Cells(k,15)=Sheets("Sheet2").TextBox1.Text Then

With Sheets("Sheet2")
If Sheets("Sheet1").Cells(k,15)=.TextBox1.Text Then
....
End With

If Sheets("Sheet1").Cells(k,15)=TextBox1.Text Then

Nothing worked.
From: GS on
Philosophaie wrote :
> I am working in Sheet2. The data is in Sheet1. I can not get the data in
> column in the 15th column to initalize the "If" even if Textbox1.Text
> matches.
>
> For k= 1 to 100
> If Sheets("Sheet1").Cells(k,15)=TextBox1.Text Then
> code...
> End if
> Next k

Lots of possibilities here! What is in Cells(k, 15)? Have you tried
specifying Cells(k, 15).Text since your evaluating it against text
stored in the textbox? We need more info in order to know how to better
help you!

regards,

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


From: Dave Peterson on
I'd add the property:

If Sheets("Sheet1").Cells(k,15).value = Sheets("Sheet2").TextBox1.Text Then

And maybe it's an upper/lower case difference:

if lcase(Sheets("Sheet1").Cells(k,15).value) _
= lcase(Sheets("Sheet2").TextBox1.Text) Then

If these don't help, I think you should try adding a msgbox before the line:

msgbox "***" & Sheets("Sheet1").Cells(k,15).value & "***" _
& "***" & sheets("sheet2").textbox1.text & "***"

To see if you can spot the difference.



Philosophaie wrote:
>
> I tried:
>
> If Sheets("Sheet1").Cells(k,15)=Sheets("Sheet2").TextBox1.Text Then
>
> With Sheets("Sheet2")
> If Sheets("Sheet1").Cells(k,15)=.TextBox1.Text Then
> ...
> End With
>
> If Sheets("Sheet1").Cells(k,15)=TextBox1.Text Then
>
> Nothing worked.

--

Dave Peterson
From: Philosophaie on
Already tried Cells(k,15).Text and .Value they did not work. I purposefully
put a number in the Textbox that exists many times in "Sheet1" row 15.

> Lots of possibilities here! What is in Cells(k, 15)? Have you tried
> specifying Cells(k, 15).Text since your evaluating it against text
> stored in the textbox? We need more info in order to know how to better
> help you!
>
> regards,
>
> --
> Garry
>
> Free usenet access at http://www.eternal-september.org
> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>
>
> .
>