ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting cells using VBA (https://www.excelbanter.com/excel-programming/420267-inserting-cells-using-vba.html)

Sreedhar

Inserting cells using VBA
 
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

--
Sreedhar

joel

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


"Sreedhar" wrote:

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

--
Sreedhar


Per Jessen[_2_]

Inserting cells using VBA
 
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

On 19 Nov., 17:38, Sreedhar
wrote:
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

--
Sreedhar



Sreedhar

Inserting cells using VBA
 
Thanks. that works.
--
Sreedhar


"Joel" wrote:

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


"Sreedhar" wrote:

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

--
Sreedhar



All times are GMT +1. The time now is 05:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com