Insert blank cells into specific columns

tlc_in_OK

Board Regular
Joined
Jun 27, 2011
Messages
56
This should be relatively simple, but I can't seem to do it. . .I need my macro to search down Column K for the first "blank" cell, and then insert blank cells in columns F thru M, shifting all cells down from there (i.e. if the first blank cell in K is K19, then insert blank cells in the range F19:M19 and shift all cells in those columns down). Can someone help me out?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Something like:
Code:
Public Sub ShiftCellsDown()
Dim lLR As Long
Dim i As Integer
lLR = Range("K" & Rows.Count).End(xlUp).Row
    For i = lLR To 2 Step -1
        If Range("K" & i).Value2 = "" Then
        Range("F" & i & ":" & "M" & i).Insert Shift:=xlDown
        End If
    Next i
End Sub
 
Upvote 0
Thanks. . .this is similar to what I had tried to do, but it doesn't do anything---never inserts the blank cells. Any ideas?
 
Upvote 0
What do you mean it doesn't do anything? I had tested it here and then posted the solution.

Are K blank cells really blank? Check if they contain characters like space etc.

Try to step through the code by using F8 on a smaller sample and see what it is upto.
 
Upvote 0
Yes, I thought of that, so I deleted everything in any cells below just in case, and still nothing. I also stepped through it, and it doesn't error, it runs through the "if" statement 17 times (the number of cells populated in K) then ends, but never inserts blank cells in the range. I can't figure it out.
 
Upvote 0
Can you post a screenshot of the data you are working on?
 
Upvote 0
Not sure how to post a screenshot here. Basically, columns F thru J are filled with numeric values to about row 34, and there are percentages in column K down to row 18. I need it to insert a section (not an entire row) of blank cells at that point. It just doesn't do it.
 
Upvote 0

Forum statistics

Threads
1,224,567
Messages
6,179,571
Members
452,927
Latest member
whitfieldcraig

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