D
Dennis
Using XL 2003 & 97
Getting a runtime error '438' in the Sub line 8 below [If
WorksheetFunction.Value....]
The function used Include is also below.
What is the correct syntax to ascertain if the Value (I think myStr) of the
cell contains numeric data?
Sub myTest()
Dim myCell As Range
Dim myStr As String
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
For Each myCell In Selection
If myCell.HasFormula = True Then
myStr = myCell.Value
If WorksheetFunction.Value(Include(myStr, "1234567890")) <> 0
Then
myCell.Interior.ColorIndex = 8
End If
End If
Next
End Sub
Function Include(StrInput As String, IncChar As String) As String
'
' From Bernie Deitrick Excel MVP 11/17/2004
'
' INCLUDE( ) returns a string consisting of only those characters from
string
' that appear in characters_to_include, in the same order that they appear
in the string.
'
' INCLUDE(string,characters_to_include)
'
' Example from ACL:
' INCLUDE("123 any street","0123456789")
' ="123"
Dim i As Integer
Include = ""
For i = 1 To Len(StrInput)
If InStr(1, IncChar, Mid(StrInput, i, 1)) > 0 Then
Include = Include & Mid(StrInput, i, 1)
End If
Next i
End Function
Getting a runtime error '438' in the Sub line 8 below [If
WorksheetFunction.Value....]
The function used Include is also below.
What is the correct syntax to ascertain if the Value (I think myStr) of the
cell contains numeric data?
Sub myTest()
Dim myCell As Range
Dim myStr As String
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
For Each myCell In Selection
If myCell.HasFormula = True Then
myStr = myCell.Value
If WorksheetFunction.Value(Include(myStr, "1234567890")) <> 0
Then
myCell.Interior.ColorIndex = 8
End If
End If
Next
End Sub
Function Include(StrInput As String, IncChar As String) As String
'
' From Bernie Deitrick Excel MVP 11/17/2004
'
' INCLUDE( ) returns a string consisting of only those characters from
string
' that appear in characters_to_include, in the same order that they appear
in the string.
'
' INCLUDE(string,characters_to_include)
'
' Example from ACL:
' INCLUDE("123 any street","0123456789")
' ="123"
Dim i As Integer
Include = ""
For i = 1 To Len(StrInput)
If InStr(1, IncChar, Mid(StrInput, i, 1)) > 0 Then
Include = Include & Mid(StrInput, i, 1)
End If
Next i
End Function