Home » excel » excel – How to check if Cell has Integer on it?

excel – How to check if Cell has Integer on it?

Posted by: admin May 14, 2020 Leave a comment

Questions:

How to check if a specific Column has Integer on each cell, and if it contains a string, Insert a blank cell to row in question.

How to&Answers:

Untested:

Dim row As Long
Dim col As Long

col = 4      ' Whatever column you want to check

For row = 1 To 100     ' How many rows you want to check
    If Not IsNumeric(Cells(row, col).Value) Then
        ' Do whatever you want to do in this case
    End If
Next row

If you clarify what you mean by “Insert a blank cell to row in question“, I will try to update my solution.

Answer:

You can check even check with a forumla that the column contains no none-numbers only

=COUNTBLANK(AAA:AAA)-COUNTBLANK(B:B)=COUNT(B:B)

where I assume that column AAA:AAA is empty.

Answer:

A mix of the other answers for bigger data.
It first checks if the colomn has none Numbers only and if not, checks where.

Dim row As Long
Dim LastRow As Long
LastRow = Range("B" & Rows.Count).End(xlUp).Row   'if you want the colomn B

If Excel.WorksheetFunction.CountBlank(Range("AAA:AAA")) - Excel.WorksheetFunction.CountBlank(Range("B:B")) = Excel.WorksheetFunction.Count(Range("B:B")) Then
For row = 1 To LastRow     

    If Not IsNumeric(Range("B" & row).Value) Then
        ' Do whatever you want to do in this case
    End If
Next row
End if