ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find Method (https://www.excelbanter.com/excel-programming/307196-find-method.html)

LiSa

Find Method
 
Hello

I have two workbooks called Alpha and Beta, which both
have one worksheet (Sheet1).
Alpha has a string in range A1 and a command button on it.
When the user clicks the button on Alpha, I want Excel to
open Beta and do a 'Find' in the Column A of Beta, for the
string that is in range A1 of Alpha.

If the string is found on Beta, then I want to
activate/select the cell two columns along on the same
row, offset(0,2), else if it doesn't find it then do
nothing.

This is my code so far which doesn't work.

Private Sub Commandbutton1_Click()
Workbooks.Open "path to Beta"
With ActiveWorkBook.Sheet1.Columns(1)
Set C = .Find(What:=ThisWorkBook.Sheet1.Range("A1"))
If Not c is Nothing



LiSa

rest of code
 
Sorry I pressed tab trying to indent code which sent it by
mistake.

Here is all the code.

Private Sub Commandbutton1_Click()
Workbooks.Open "path to Beta"
With ActiveWorkBook.Sheet1.Columns(1)
Set C = .Find(What:=ThisWorkBook.Sheet1.Range("A1"))
If Not c is Nothing
c.address.offset(0,2).activate
end if
end with
end sub

-----Original Message-----
Hello

I have two workbooks called Alpha and Beta, which both
have one worksheet (Sheet1).
Alpha has a string in range A1 and a command button on it.
When the user clicks the button on Alpha, I want Excel to
open Beta and do a 'Find' in the Column A of Beta, for

the
string that is in range A1 of Alpha.

If the string is found on Beta, then I want to
activate/select the cell two columns along on the same
row, offset(0,2), else if it doesn't find it then do
nothing.

This is my code so far which doesn't work.

Private Sub Commandbutton1_Click()
Workbooks.Open "path to Beta"
With ActiveWorkBook.Sheet1.Columns(1)
Set C = .Find(What:=ThisWorkBook.Sheet1.Range("A1"))
If Not c is Nothing


.


Don Guillett[_4_]

Find Method
 
See if this helps

Sub resizefind()
With Sheet1.Columns(1)
Set c = .Find(What:=Sheet1.Range("b1"))
If Not c Is Nothing Then c.Resize(1, 3).Select
End With
End Sub

--
Don Guillett
SalesAid Software

"LiSa" wrote in message
...
Hello

I have two workbooks called Alpha and Beta, which both
have one worksheet (Sheet1).
Alpha has a string in range A1 and a command button on it.
When the user clicks the button on Alpha, I want Excel to
open Beta and do a 'Find' in the Column A of Beta, for the
string that is in range A1 of Alpha.

If the string is found on Beta, then I want to
activate/select the cell two columns along on the same
row, offset(0,2), else if it doesn't find it then do
nothing.

This is my code so far which doesn't work.

Private Sub Commandbutton1_Click()
Workbooks.Open "path to Beta"
With ActiveWorkBook.Sheet1.Columns(1)
Set C = .Find(What:=ThisWorkBook.Sheet1.Range("A1"))
If Not c is Nothing





Don Guillett[_4_]

Find Method
 
If you only want to select the cell that is 2 columns to the right then use
this line.
If Not c Is Nothing Then c.Offset(0, 2).Select

However, what do you want to select it for. You can use it without
selecting.
then c.offset(0,2)=5

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
See if this helps

Sub resizefind()
With Sheet1.Columns(1)
Set c = .Find(What:=Sheet1.Range("b1"))
If Not c Is Nothing Then c.Resize(1, 3).Select
End With
End Sub

--
Don Guillett
SalesAid Software

"LiSa" wrote in message
...
Hello

I have two workbooks called Alpha and Beta, which both
have one worksheet (Sheet1).
Alpha has a string in range A1 and a command button on it.
When the user clicks the button on Alpha, I want Excel to
open Beta and do a 'Find' in the Column A of Beta, for the
string that is in range A1 of Alpha.

If the string is found on Beta, then I want to
activate/select the cell two columns along on the same
row, offset(0,2), else if it doesn't find it then do
nothing.

This is my code so far which doesn't work.

Private Sub Commandbutton1_Click()
Workbooks.Open "path to Beta"
With ActiveWorkBook.Sheet1.Columns(1)
Set C = .Find(What:=ThisWorkBook.Sheet1.Range("A1"))
If Not c is Nothing







Tom Ogilvy

rest of code
 
Private Sub Commandbutton1_Click()
Workbooks.Open "path to Beta"
With ActiveWorkBook.worksheets(1).Columns(1)
Set C = .Find(What:=ThisWorkBook.worksheets(1).Range("A1") )
If Not c is Nothing
c.offset(0,2).activate
end if
end with
end sub

--
Regards,
Tom Ogilvy


"LiSa" wrote in message
...
Sorry I pressed tab trying to indent code which sent it by
mistake.

Here is all the code.

Private Sub Commandbutton1_Click()
Workbooks.Open "path to Beta"
With ActiveWorkBook.Sheet1.Columns(1)
Set C = .Find(What:=ThisWorkBook.Sheet1.Range("A1"))
If Not c is Nothing
c.address.offset(0,2).activate
end if
end with
end sub

-----Original Message-----
Hello

I have two workbooks called Alpha and Beta, which both
have one worksheet (Sheet1).
Alpha has a string in range A1 and a command button on it.
When the user clicks the button on Alpha, I want Excel to
open Beta and do a 'Find' in the Column A of Beta, for

the
string that is in range A1 of Alpha.

If the string is found on Beta, then I want to
activate/select the cell two columns along on the same
row, offset(0,2), else if it doesn't find it then do
nothing.

This is my code so far which doesn't work.

Private Sub Commandbutton1_Click()
Workbooks.Open "path to Beta"
With ActiveWorkBook.Sheet1.Columns(1)
Set C = .Find(What:=ThisWorkBook.Sheet1.Range("A1"))
If Not c is Nothing


.





All times are GMT +1. The time now is 04:55 PM.

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