ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Find and Replace (https://www.excelbanter.com/excel-programming/324511-using-find-replace.html)

Nigel Bennett

Using Find and Replace
 
What I need to do is find a value in a column and then
have the column directly to the right of that become the
active cell regardless of how far down the spreadsheet it
may be

eg I am looking for the word category in column B One day
it is in cell B56 so I want to refrence cell C56, the next
day it is in cell b45 I want to reference cell C45

Hope someone can help

Thanks



Jim Thomlinson[_3_]

Using Find and Replace
 
Your question is a little unclear but this code will find a string and move
the active cell one cell to the right of it. The code is mighty generic so
you can select whatever range you ant to serach on whatever sheet you want to
search.

Sub test()
Call FindString("1") 'Implementation
End Sub

Public Sub FindString(ByVal strTextToFind As String)
Dim wksCurrent As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range

Set wksCurrent = ActiveSheet
Set rngToSearch = wksCurrent.Range("B1").EntireColumn
Set rngFound = rngToSearch.Find(strTextToFind)

If Not rngFound Is Nothing Then rngFound.Offset(0, 1).Select
End Sub



"Nigel Bennett" wrote:

What I need to do is find a value in a column and then
have the column directly to the right of that become the
active cell regardless of how far down the spreadsheet it
may be

eg I am looking for the word category in column B One day
it is in cell B56 so I want to refrence cell C56, the next
day it is in cell b45 I want to reference cell C45

Hope someone can help

Thanks




Otto Moehrbach

Using Find and Replace
 
One way:
Columns("B:B").Find(What:="category",
LookAt:=xlWhole).Offset(,1).Activate



All the above is on one line. HTH Otto

"Nigel Bennett" wrote in message
...
What I need to do is find a value in a column and then
have the column directly to the right of that become the
active cell regardless of how far down the spreadsheet it
may be

eg I am looking for the word category in column B One day
it is in cell B56 so I want to refrence cell C56, the next
day it is in cell b45 I want to reference cell C45

Hope someone can help

Thanks





No Name

Using Find and Replace
 
This works but I have one further question

How do I make so that it finds only that word not the
first instance, it must match the word exactly

currently if finds "sub category" and I want ot to find
only the cell where the word is Category"


thanks


-----Original Message-----
Your question is a little unclear but this code will

find a string and move
the active cell one cell to the right of it. The code is

mighty generic so
you can select whatever range you ant to serach on

whatever sheet you want to
search.

Sub test()
Call FindString("1") 'Implementation
End Sub

Public Sub FindString(ByVal strTextToFind As String)
Dim wksCurrent As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range

Set wksCurrent = ActiveSheet
Set rngToSearch = wksCurrent.Range("B1").EntireColumn
Set rngFound = rngToSearch.Find(strTextToFind)

If Not rngFound Is Nothing Then rngFound.Offset(0,

1).Select
End Sub



"Nigel Bennett" wrote:

What I need to do is find a value in a column and then
have the column directly to the right of that become

the
active cell regardless of how far down the spreadsheet

it
may be

eg I am looking for the word category in column B One

day
it is in cell B56 so I want to refrence cell C56, the

next
day it is in cell b45 I want to reference cell C45

Hope someone can help

Thanks



.



All times are GMT +1. The time now is 01:53 PM.

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