I am looking for a code that loops through the selected cells and checks every cell it contains formula AND a numeric value, like to find cell A2
A B C
1 5=A1=B1+C1 4 1
2 7=A1=B1+C1+2 4 1
I found code that is close to match, because it finds formula, it do not recognize numerical value in formula
Sub AllNummericCells()
Dim rCcells As Range, rFcells As Range
Dim rAcells As Range
'Set variable to all used cells
Set rAcells = ActiveSheet.UsedRange
On Error Resume Next 'In case of no numeric formula or constants.
'Set variable to all numeric constants
Set rCcells = rAcells.SpecialCells(xlCellTypeConstants, xlNumbers)
'Set variable to all numeric formulas
Set rFcells = rAcells.SpecialCells(xlCellTypeFormulas, xlNumbers)
'Determine which type of numeric data (formulas, constants or none)
If rCcells Is Nothing And rFcells Is Nothing Then
MsgBox "You Worksheet contains no numbers"
End
ElseIf rCcells Is Nothing Then
Set rAcells = rFcells 'formulas
ElseIf rFcells Is Nothing Then
Set rAcells = rCcells 'constants
Else
Set rAcells = Application.Union(rFcells, rCcells) 'Both
End If
On Error GoTo 0
rAcells.Select
End Sub
any tips
A B C
1 5=A1=B1+C1 4 1
2 7=A1=B1+C1+2 4 1
I found code that is close to match, because it finds formula, it do not recognize numerical value in formula
Sub AllNummericCells()
Dim rCcells As Range, rFcells As Range
Dim rAcells As Range
'Set variable to all used cells
Set rAcells = ActiveSheet.UsedRange
On Error Resume Next 'In case of no numeric formula or constants.
'Set variable to all numeric constants
Set rCcells = rAcells.SpecialCells(xlCellTypeConstants, xlNumbers)
'Set variable to all numeric formulas
Set rFcells = rAcells.SpecialCells(xlCellTypeFormulas, xlNumbers)
'Determine which type of numeric data (formulas, constants or none)
If rCcells Is Nothing And rFcells Is Nothing Then
MsgBox "You Worksheet contains no numbers"
End
ElseIf rCcells Is Nothing Then
Set rAcells = rFcells 'formulas
ElseIf rFcells Is Nothing Then
Set rAcells = rCcells 'constants
Else
Set rAcells = Application.Union(rFcells, rCcells) 'Both
End If
On Error GoTo 0
rAcells.Select
End Sub
any tips