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.

Array 1Output
Name 1Name 1
Name 2Name 2
Name 4
Name 4Name 5
Name 5Name 6
Name 6Name 8
Name 8

<tbody>
</tbody>
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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.

Array 1Output
Name 1Name 1
Name 2Name 2
Name 4
Name 4Name 5
Name 5Name 6
Name 6Name 8
Name 8

<tbody>
</tbody>
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,214,653
Messages
6,120,756
Members
448,990
Latest member
Buzzlightyear

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