Shifting empty cells

dantzler

Board Regular
Joined
Jun 2, 2011
Messages
156
I am new to macros.
Can some one please help me figure out how to do this?

I need to search all the cells in column one and whenever it finds an empty cell insert 6 blank cells shifting the entire row to the right.

I have tried this several ways and can not get the syntax right.

Thanks for your help
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Welcome to MrExcel board...

try this

Code:
Sub FindBlanks()
Dim LR As Long, i As Long
LR = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
    
For i = 2 To LR
    If Cells(i, "D") = "" Then
        Range(Cells(i, 1), Cells(i, 1 + 5)).Insert Shift:=xlToRight
    End If
Next i
End Sub
 
Upvote 0
That worked great.
Not at all how I was trying.
In fact I can not understand this line at all [If Cells(i, "D") = "" Then].
Are you searching for the Character "D" ?
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,917
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top