Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default InStr Help - Multiple Criteria

This is the line of code I'm working on (Full code below):

myInStr = InStr(c.Formula, "Cog1")

What I would like it to be able to do is find anythinf with a "Cog1"
or "Cog2" or "Cog3." Right now it works perfect with one criteria,
but I would like to open it up to more.

Is there a quick and easy way to do this?

Thanks,

Tyson


Sub Values()
Dim c
Dim myInStr As String
Dim cRange As Range

Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

On Error Resume Next
Set cRange = Cells.SpecialCells(xlCellTypeFormulas, 23)

For Each c In cRange
myInStr = InStr(c.Formula, "Cog1")
If myInStr < 0 Then
Range(c.Address) = Range(c.Address).Value
End If
Next c

On Error GoTo 0
ActiveSheet.Range("A1").Select
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default InStr Help - Multiple Criteria

Will this work?
myInStr = InStr(c.Formula, "Cog1" Or "Cog2" Or "Cog3")

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"TysonE" wrote:

This is the line of code I'm working on (Full code below):

myInStr = InStr(c.Formula, "Cog1")

What I would like it to be able to do is find anythinf with a "Cog1"
or "Cog2" or "Cog3." Right now it works perfect with one criteria,
but I would like to open it up to more.

Is there a quick and easy way to do this?

Thanks,

Tyson


Sub Values()
Dim c
Dim myInStr As String
Dim cRange As Range

Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

On Error Resume Next
Set cRange = Cells.SpecialCells(xlCellTypeFormulas, 23)

For Each c In cRange
myInStr = InStr(c.Formula, "Cog1")
If myInStr < 0 Then
Range(c.Address) = Range(c.Address).Value
End If
Next c

On Error GoTo 0
ActiveSheet.Range("A1").Select
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default InStr Help - Multiple Criteria

No, I tired that already. That will actually turn all formulas into
values. Any other ideas?

On Aug 3, 9:56*am, ryguy7272
wrote:
Will this work?
myInStr = InStr(c.Formula, "Cog1" Or "Cog2" Or "Cog3")

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''..



"TysonE" wrote:
This is the line of code I'm working on (Full code below):


myInStr = InStr(c.Formula, "Cog1")


What I would like it to be able to do is find anythinf with a "Cog1"
or "Cog2" or "Cog3." *Right now it works perfect with one criteria,
but I would like to open it up to more.


Is there a quick and easy way to do this?


Thanks,


Tyson


Sub Values()
Dim c
Dim myInStr As String
Dim cRange As Range


Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False


On Error Resume Next
Set cRange = Cells.SpecialCells(xlCellTypeFormulas, 23)


* * For Each c In cRange
* * * * myInStr = InStr(c.Formula, "Cog1")
* * * * If myInStr < 0 Then
* * * * * *Range(c.Address) = Range(c.Address).Value
* * * * End If
* * Next c


On Error GoTo 0
ActiveSheet.Range("A1").Select
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default InStr Help - Multiple Criteria

What about just removing the number and then testing for the range
afterwards? Something like this maybe...

For Each c In cRange
myInStr = InStr(c.Formula, "Cog")
If myInStr < 0 Then
If Mid(c.Formula, myInStr + 3, 1) < 3 and Mid(c.Formula, _
myInStr + 4, 1) Like "[!0-9]" Then
Range(c.Address) = Range(c.Address).Value
End If
End If
Next c

--
Rick (MVP - Excel)


"TysonE" wrote in message
...
This is the line of code I'm working on (Full code below):

myInStr = InStr(c.Formula, "Cog1")

What I would like it to be able to do is find anythinf with a "Cog1"
or "Cog2" or "Cog3." Right now it works perfect with one criteria,
but I would like to open it up to more.

Is there a quick and easy way to do this?

Thanks,

Tyson


Sub Values()
Dim c
Dim myInStr As String
Dim cRange As Range

Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

On Error Resume Next
Set cRange = Cells.SpecialCells(xlCellTypeFormulas, 23)

For Each c In cRange
myInStr = InStr(c.Formula, "Cog1")
If myInStr < 0 Then
Range(c.Address) = Range(c.Address).Value
End If
Next c

On Error GoTo 0
ActiveSheet.Range("A1").Select
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SUMIFS, one criteria range, multiple criteria GavinS Excel Worksheet Functions 2 September 7th 11 05:40 PM
match multiple criteria ina range from multiple criteria multiplet RG Excel Worksheet Functions 8 September 28th 07 04:21 AM
Index & Match functions - multiple criteria and multiple results [email protected] Excel Worksheet Functions 4 May 2nd 07 03:13 AM
Counting Cells with multiple criteria.One criteria supporting wild Azhar Saleem Excel Worksheet Functions 1 January 12th 05 10:54 AM
Counting Cells with multiple criteria.One criteria supporting wild Azhar Arain Excel Worksheet Functions 1 January 12th 05 08:33 AM


All times are GMT +1. The time now is 04:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"