I have a column with both text and numeric values due to some data import format.
I am trying to insert a single cell if it contains a number. I am using the below code which works at only shifting the cells with numbers in them, however it is inconsistent with the number of cells it inserts. Sometimes it will insert 1 and then it will insert anywhere from 3-6 on other rows that meet the criteria. I've tried using both 8 and "H". Any idea why?
Public Sub Shift()
Dim i As Integer
For i = 1 To 300
If IsNumeric(Cells(i, 8)) = True Then Cells(i, 8).Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Next i
End Sub
I am trying to insert a single cell if it contains a number. I am using the below code which works at only shifting the cells with numbers in them, however it is inconsistent with the number of cells it inserts. Sometimes it will insert 1 and then it will insert anywhere from 3-6 on other rows that meet the criteria. I've tried using both 8 and "H". Any idea why?
Public Sub Shift()
Dim i As Integer
For i = 1 To 300
If IsNumeric(Cells(i, 8)) = True Then Cells(i, 8).Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Next i
End Sub