Insert Blank Lines Based on Cell

JPSailes

New Member
Joined
Mar 16, 2018
Messages
4
Currently using .Range (G4) to determine number of blank rows. However, what I need is for the range to be entire column G:G (that are not null). A better way?

Code:
With ws
    Set NBOFROWS = .Range(G4)
    ActiveCell.EntireRow.Offset(1).Resize(NBOFROWS.Value).Insert Shift:=xlDown
  End With

Ultimately, I'm copying down Row based on G. Using the below. So probably an easier route than this.
Code:
Columns("A:A").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = "=R[-1]C"
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi,

What do you have in G4 ?

To get count of blank values in a range :

Code:
nbEmpty = Columns("G:G").SpecialCells(xlCellTypeBlanks).Count

It is never a good solution to use Select. You can just do :

Code:
Columns("A:A").SpecialCells(xlCellTypeBlanks).FormulaR1C1 = ...
 
Last edited:
Upvote 0
Thanks. G4, or all the G:G contains the number of cells I need to insert blanks below (and ultimately fill down).

So if G4 is 5, I need to insert 5 blank rows below Row 4.

In theory, if I could use the current cell selection, I could make this work using relative references. But it seems it would be ugly.

I don't have permission to attach example.
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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