Inserting cells using VBA

S

Sreedhar

Hi,

I want a macro that inserts cells at column "F" and shifts the cells right
<IF> the cell value at column "H" meets certain criteria.

something like:
For each cell in Range(H1:H3500")
If IsNumeric(cell.value) Then 'only numbers, nulls
excluded
''''Insert three cells at "F" and shift right
End If
Next cell

Thanks
 
J

Joel

For RowCount = 1 To 3500
If IsNumeric(Range("H" & RowCount).Value) Then
Range("F" & RowCount).Insert Shift:=xlToRight
End If
Next RowCount
 
P

Per Jessen

Hi

Try this:

Dim cell As Range
For Each cell In Range("H1:H3500")
If IsNumeric(cell.Value) Then 'only numbers, nulls excluded
cell.Resize(1, 3).Insert Shift:=xlShiftToRight
End If
Next cell

Regards,
Per
 
S

Sreedhar

Thanks. that works.
--
Sreedhar


Joel said:
For RowCount = 1 To 3500
If IsNumeric(Range("H" & RowCount).Value) Then
Range("F" & RowCount).Insert Shift:=xlToRight
End If
Next RowCount
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top