ThrottleWorks
Excel Ninja
Hi,
Sorry for the confusing subject line.
I am using below code for doing control F.
I am finding a string defined as rn from a file.
The problem is rn may or may not be present in the file.
If rn (string value) is not present, then the code gives bug.
Run-Time Error 91
If the code gives bug or if the rn is not present I have to change my rn value and search again.
For example, my rn value is "A". The value is not present in the file.
So the macro will give bug, in this case I want to find rn.offset(0,1).
The reason is, I have 2 columns. Column A and Column B.
If cell("A1").value is giving bug then I have to find cell("b1").value in the same file.
I know how to write "If then End if" but do not know how to write if there is an error.
If I use on error resume next, then that is also wrong.
I am trying to write code in below fashion but not able to do it
If first control find result = error then excute below code.
Can anyone please help me in this.
Sorry for the confusing subject line.
I am using below code for doing control F.
Code:
Cells.Find(What:=rn, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
I am finding a string defined as rn from a file.
The problem is rn may or may not be present in the file.
If rn (string value) is not present, then the code gives bug.
Run-Time Error 91
If the code gives bug or if the rn is not present I have to change my rn value and search again.
For example, my rn value is "A". The value is not present in the file.
So the macro will give bug, in this case I want to find rn.offset(0,1).
The reason is, I have 2 columns. Column A and Column B.
If cell("A1").value is giving bug then I have to find cell("b1").value in the same file.
I know how to write "If then End if" but do not know how to write if there is an error.
If I use on error resume next, then that is also wrong.
I am trying to write code in below fashion but not able to do it
If first control find result = error then excute below code.
Code:
Cells.Find(What:=rn.offset(0,1), After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Can anyone please help me in this.