Remove blank cells from an array

vivek456

New Member
Joined
Feb 28, 2018
Messages
5
Hello - I have an array with different names (Array 1). I want to remove the blanks in this column & create an output in another column, where the blanks are removed. I have attempted to do this however I am struggling to achieve this. :(Any help on this would be much appreciated. Any advise in doing this via a macro approach or a formula based approach would be much appreciated.

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Array 1[/TD]
[TD]Output[/TD]
[/TR]
[TR]
[TD]Name 1[/TD]
[TD]Name 1[/TD]
[/TR]
[TR]
[TD]Name 2[/TD]
[TD]Name 2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Name 4[/TD]
[/TR]
[TR]
[TD]Name 4[/TD]
[TD]Name 5[/TD]
[/TR]
[TR]
[TD]Name 5[/TD]
[TD]Name 6[/TD]
[/TR]
[TR]
[TD]Name 6[/TD]
[TD]Name 8[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Name 8[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
For a macro approach, try this in a copy of your workbook.
Code:
Sub NewList()
  With Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row)
    .Value = .Offset(, -1).Value
    On Error Resume Next
    .SpecialCells(xlBlanks).Delete Shift:=xlUp
    On Error GoTo 0
  End With
End Sub
 
Upvote 0
Hello - I have an array with different names (Array 1). I want to remove the blanks in this column & create an output in another column, where the blanks are removed. I have attempted to do this however I am struggling to achieve this. :(Any help on this would be much appreciated. Any advise in doing this via a macro approach or a formula based approach would be much appreciated.

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Array 1[/TD]
[TD]Output[/TD]
[/TR]
[TR]
[TD]Name 1[/TD]
[TD]Name 1[/TD]
[/TR]
[TR]
[TD]Name 2[/TD]
[TD]Name 2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Name 4[/TD]
[/TR]
[TR]
[TD]Name 4[/TD]
[TD]Name 5[/TD]
[/TR]
[TR]
[TD]Name 5[/TD]
[TD]Name 6[/TD]
[/TR]
[TR]
[TD]Name 6[/TD]
[TD]Name 8[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Name 8[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Your layout is not entirely clear, but let's assume your names list with the blanks is in Column A and starts on Row 2 and that the output list should start on cell B2. I am also assuming your names list are constants (that is, not formula results). Given those assumptions, this single line of code will produce the list you want...
Code:
[table="width: 500"]
[tr]
	[td]Range("A2", Cells(Rows.Count, "A").End(xlUp)).SpecialCells(xlConstants).Copy Range("B2")[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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