ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Do Loop or use End iF for search string (https://www.excelbanter.com/excel-discussion-misc-queries/241169-do-loop-use-end-if-search-string.html)

RGreen

Do Loop or use End iF for search string
 
50 colums (BI:DC) 1500 rows (500 to 2000)
On the cs772nd row, cs797th row, cs822nd row and so on, in each column I
have the word "stop".
The data is already stored or I am storing data into these colums:

Depending on where I am storing data, I would like to search that column for
the word stop, and I want my active cell to be just above the word stop.

SO If I am in CU775 (Activecell) than I would like to search that column CU
for the word stop down to row 797 and my active cell would be CU796.

What would be the best way for me to approach this with not too much coding
as I need to accomodate this to another marco already in place.

Thanks,
Rick


Stefi

Do Loop or use End iF for search string
 
Try this:

Cells(Columns(ActiveCell.Column).Find(What:="stop" , _
After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Row - 1, ActiveCell.Column).Select

You may have to apply On Error for handling cases when "stop" is not found!

Regards,
Stefi

€˛RGreen€¯ ezt Ć*rta:

50 colums (BI:DC) 1500 rows (500 to 2000)
On the cs772nd row, cs797th row, cs822nd row and so on, in each column I
have the word "stop".
The data is already stored or I am storing data into these colums:

Depending on where I am storing data, I would like to search that column for
the word stop, and I want my active cell to be just above the word stop.

SO If I am in CU775 (Activecell) than I would like to search that column CU
for the word stop down to row 797 and my active cell would be CU796.

What would be the best way for me to approach this with not too much coding
as I need to accomodate this to another marco already in place.

Thanks,
Rick


Jacob Skaria

Do Loop or use End iF for search string
 
Try the below macro

Sub Macro()
Dim varFound As Variant
Set varFound = Columns(ActiveCell.Column).Find("Stop")
If Not varfound Is Nothing Then varfound.Offset(-1, 0).Activate
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"RGreen" wrote:

50 colums (BI:DC) 1500 rows (500 to 2000)
On the cs772nd row, cs797th row, cs822nd row and so on, in each column I
have the word "stop".
The data is already stored or I am storing data into these colums:

Depending on where I am storing data, I would like to search that column for
the word stop, and I want my active cell to be just above the word stop.

SO If I am in CU775 (Activecell) than I would like to search that column CU
for the word stop down to row 797 and my active cell would be CU796.

What would be the best way for me to approach this with not too much coding
as I need to accomodate this to another marco already in place.

Thanks,
Rick


Jacob Skaria

Do Loop or use End iF for search string
 
Oops...correction..

Sub Macro()
Dim varFound As Variant
Set varFound = Range(ActiveCell, Cells(Rows.Count, _
ActiveCell.Column).End(xlUp)).Find("Stop")
If Not varFound Is Nothing Then varFound.Offset(-1, 0).Activate
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Try the below macro

Sub Macro()
Dim varFound As Variant
Set varFound = Columns(ActiveCell.Column).Find("Stop")
If Not varfound Is Nothing Then varfound.Offset(-1, 0).Activate
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"RGreen" wrote:

50 colums (BI:DC) 1500 rows (500 to 2000)
On the cs772nd row, cs797th row, cs822nd row and so on, in each column I
have the word "stop".
The data is already stored or I am storing data into these colums:

Depending on where I am storing data, I would like to search that column for
the word stop, and I want my active cell to be just above the word stop.

SO If I am in CU775 (Activecell) than I would like to search that column CU
for the word stop down to row 797 and my active cell would be CU796.

What would be the best way for me to approach this with not too much coding
as I need to accomodate this to another marco already in place.

Thanks,
Rick


RGreen

Do Loop or use End iF for search string
 
Hey Jacob, this did the trick

Stefi, haven't tried it yet, but thanks for the posting.

Rick.

"Jacob Skaria" wrote:

Try the below macro

Sub Macro()
Dim varFound As Variant
Set varFound = Columns(ActiveCell.Column).Find("Stop")
If Not varfound Is Nothing Then varfound.Offset(-1, 0).Activate
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"RGreen" wrote:

50 colums (BI:DC) 1500 rows (500 to 2000)
On the cs772nd row, cs797th row, cs822nd row and so on, in each column I
have the word "stop".
The data is already stored or I am storing data into these colums:

Depending on where I am storing data, I would like to search that column for
the word stop, and I want my active cell to be just above the word stop.

SO If I am in CU775 (Activecell) than I would like to search that column CU
for the word stop down to row 797 and my active cell would be CU796.

What would be the best way for me to approach this with not too much coding
as I need to accomodate this to another marco already in place.

Thanks,
Rick



All times are GMT +1. The time now is 11:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com