ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Convert Excel IF ISERROR formula to VBA (https://www.excelbanter.com/excel-programming/443943-convert-excel-if-iserror-formula-vba.html)

u473

Convert Excel IF ISERROR formula to VBA
 
Found = ""
For Each cell In Rng
'The following formula works in Excel
'nFound = left(B6,if(iserror(Find(" 3.",B6)),0,Find(" 3.",B6)))
'
' However, all my syntax variations to adapt it in VBA do not work.
Can you help me
'
nFound = "=left(cell.value,if iserror(Find(' 3.',cell.value)),
0,Find(' 3.',cell.value))"
If nFound < Found Then
'Copy Row ........
Found = nFound
End If
Next cell
'
Help appreciated.

Dave Peterson[_2_]

Convert Excel IF ISERROR formula to VBA
 
Look at VBA's help for InStr. It's the VBA equivalent of Excel's =Find()/=Search().



On 11/24/2010 19:37, u473 wrote:
Found = ""
For Each cell In Rng
'The following formula works in Excel
'nFound = left(B6,if(iserror(Find(" 3.",B6)),0,Find(" 3.",B6)))
'
' However, all my syntax variations to adapt it in VBA do not work.
Can you help me
'
nFound = "=left(cell.value,if iserror(Find(' 3.',cell.value)),
0,Find(' 3.',cell.value))"
If nFound< Found Then
'Copy Row ........
Found = nFound
End If
Next cell
'
Help appreciated.


--
Dave Peterson


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

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