![]() |
Need to program a find only in one column
Hi. I need to use the find tool in Excel but only for one column. How I can do this?:rolleyes: I have this: Private Sub cmdTSearch_Click() Dim DATA As String DATA = txtTicket.Text If txtTicket.Text = "" Then MsgBox ("Text Box Empty") Else With Worksheets("Info").Range("X4:X700") Set B = Cells.Find(What:=DATA, After:=ActiveCell, LookIn:=xlValues, LookAt:= _ xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=True) If B Is Nothing Then MsgBox ("Nothing Found") Else Range("X4:X500").Select Cells.Find(What:=DATA, After:=ActiveCell, LookIn:=xlValues, LookAt:= _ xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=True).Activate End If 'MsgBox ActiveWindow.RangeSelection.Address End With End If End Sub Thanks. Angel -- xrckiss ------------------------------------------------------------------------ xrckiss's Profile: http://www.excelforum.com/member.php...o&userid=33065 View this thread: http://www.excelforum.com/showthread...hreadid=528787 |
Need to program a find only in one column
I think you need a period in front of Cells (otherwise it refers to all of
the cells on the worksheet). You probably also want to qualify After to use the first cell in X4:X700 instead of the active cell (but I've not tested to see if it makes a difference). With Worksheets("Info").Range("X4:X700") Set B = .Cells.Find(What:=DATA, After:=.Cells(1,1), LookIn:=xlValues Also, at the end of your code, if B is not nothing you should not have to perform the Find operation again, just activate the cell with B.Activate assuming the worksheet containing B is the active sheet (otherwise, you have to activate the proper worksheet, then activate B). "xrckiss" wrote: Hi. I need to use the find tool in Excel but only for one column. How I can do this?:rolleyes: I have this: Private Sub cmdTSearch_Click() Dim DATA As String DATA = txtTicket.Text If txtTicket.Text = "" Then MsgBox ("Text Box Empty") Else With Worksheets("Info").Range("X4:X700") Set B = Cells.Find(What:=DATA, After:=ActiveCell, LookIn:=xlValues, LookAt:= _ xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=True) If B Is Nothing Then MsgBox ("Nothing Found") Else Range("X4:X500").Select Cells.Find(What:=DATA, After:=ActiveCell, LookIn:=xlValues, LookAt:= _ xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=True).Activate End If 'MsgBox ActiveWindow.RangeSelection.Address End With End If End Sub Thanks. Angel -- xrckiss ------------------------------------------------------------------------ xrckiss's Profile: http://www.excelforum.com/member.php...o&userid=33065 View this thread: http://www.excelforum.com/showthread...hreadid=528787 |
Need to program a find only in one column
Thanks JMB. Worked just fine. -- xrckiss ------------------------------------------------------------------------ xrckiss's Profile: http://www.excelforum.com/member.php...o&userid=33065 View this thread: http://www.excelforum.com/showthread...hreadid=528787 |
All times are GMT +1. The time now is 12:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com