Remove blank cells in a given range (remove gaps between cells)

thedeadzeds

Active Member
Joined
Aug 16, 2011
Messages
442
Office Version
  1. 365
Platform
  1. Windows
Guys, is there a way to via vba move all of the names so there are no gaps so example 1 looks like example 2. The data is currerntly in range c22 to E40 in sheet called 'Allocate'

EXAMPLE 1
Name1Name2Name3
Angela Rose
Bethan Mason Angela Rose
Chloe WhitfieldBethan Mason
Angela Rose
Chloe Whitfield
Angela Rose
Lorna Young
Bethan Mason
Nicole Foxwell

<colgroup><col span="2"><col></colgroup><tbody>
</tbody>

EXAMPLE 2
Name1Name2Name3
Angela RoseBethan MasonAngela Rose
Bethan MasonChloe WhitfieldAngela Rose
Chloe WhitfieldBethan MasonAngela Rose
Lorna Young
Nicole Foxwell

<colgroup><col span="2"><col></colgroup><tbody>
</tbody>
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG16Nov56
[COLOR="Navy"]Dim[/COLOR] rng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] rng = Range("A:c").SpecialCells(xlCellTypeBlanks)
rng.Delete shift:=xlUp
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
try
Code:
Sub removeblanks()
Range("C22:E40").SpecialCells(xlBlanks).Delete xlShiftUp
End Sub
 
Last edited:
Upvote 0
You can also:- Select area.
Then "Home" > "Find & Select" > "Go to special" > "Blank"> "Ok.
Right click Area, "Select Delete" > "shift Cells Up" > "OK"
 
Upvote 0

Forum statistics

Threads
1,214,917
Messages
6,122,233
Members
449,075
Latest member
staticfluids

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