Prev: How to change to active sheet on macro?
Next: Change color of row (Col A thru Col Q) based on text value in Col J
From: Philosophaie on 1 Jun 2010 12:59 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 1 Jun 2010 13:25 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 1 Jun 2010 14:27 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 1 Jun 2010 14:29 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 1 Jun 2010 15:18
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 > > > . > |