Find value with the help of macro.

H

Heera

Hi,

Normally in excel we find a value with the help of ctrl+F and then
find it.

But when i recored a macro to do the same it is giving an error can
some help me to solve this issue.

All the values in my sheet are unique value.

Regards

Heera
 
D

Dave Peterson

I'm guessing you recorded a macro when you tried to find something. And in that
recorded code, there was a .activate line.

If the value wasn't found, then the .activate will fail.

Dim FoundCell as range
set foundcell = activesheet.range("a1:b99").find(....)

if foundcell is nothing then
msgbox "not found"
else
foundcell.select
end if
 
H

Heera

My problem is this.

I have two workbooks.

In 1st workbook there is a value.


My macro should go to the 2nd workbook and find the value of 1st
workbook on which my cursor is.


for example 1st workbooks has a value 50K in C6 cell
then My macro should go in 2nd workbook and find 50K in selected
range.
then again it should come back to the C6 cell of 1st workbook.

Again the same loop for the cell value which is there in C7.

I recoreded a Macro of (ctrl+f ) but it is giving an error.


Regards


Heera
 
A

Arvi Laanemets

Hi

Here is something I did write on fly - check this out.

------
Sub SearchEntry()

Dim MyString As String
Dim MyCase As Boolean

MyString = InputBox("Enter the string to search!")
MyCase = MsgBox("Do you want the search to be case sensitive?", vbYesNo)

On Error GoTo NoString

ActiveSheet.UsedRange.Find(What:=MyString, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=MyCase).Activate
Exit Sub

NoString:
MsgBox "The string was not found!"

End Sub
 
D

Dave Peterson

Share what your code is so far.
My problem is this.

I have two workbooks.

In 1st workbook there is a value.

My macro should go to the 2nd workbook and find the value of 1st
workbook on which my cursor is.

for example 1st workbooks has a value 50K in C6 cell
then My macro should go in 2nd workbook and find 50K in selected
range.
then again it should come back to the C6 cell of 1st workbook.

Again the same loop for the cell value which is there in C7.

I recoreded a Macro of (ctrl+f ) but it is giving an error.

Regards

Heera
 
H

Heera

Thank you Dave and Arvi both of your codes were helpfull in a
different way.......I got the hint looking at your code....thanks a
lot....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top