如何检查单元格是否有整数?

如何检查每个单元格上的特定列是否具有整数,如果它包含一个string,请将空白单元格插入到有问题的行中。

未经testing:

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 

如果你通过“将一个空白单元格插入有问题的行澄清你的意思,我将尝试更新我的解决scheme。

你甚至可以检查一个论坛,该列只包含非数字

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

在那里我假设列AAA:AAA是空的。

大数据的其他答案的混合。 它首先检查colomn是否只有数字,如果没有,检查在哪里。

 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