I should add that if any of the cells are not numeric, I would like to insert a new column.
Right now this is what I have.
Code:
For Each n In Range("A2:A13")
If Not IsNumeric(n) Then
Msgbox "Numeric", vbOKOnly, "What is What"
End If
Next n
This will go through each cell and determine if the cell value is numeric.
How do I break out of the For Each if a non numeric value is found so I can insert a new column? If I just use the if as is, I will end up iserting a new column every time I encounter a non numeric value.
VD
For a large range, you can do away with the loop...
Code:
Sub CheckForNumerics()
Dim r As Range, s As Range
Set s = Selection
On Error Resume Next
Set r = s.SpecialCells(xlCellTypeConstants, 1)
If Not r Is Nothing Then MsgBox "There are numerics in the selection."
s.Select
End Sub
The "On Error Resume Next" is there because an error will be generated if there are no special cells of that type available in the defined range.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.