Deleting spaces from blank cell in sheet?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,976
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone.
I need a macro that can help me clean up my data range.
We export data from our CRM system which is very old and the data needs sorting out before i can do anything with it.
I've done most of the macros but am stuck and looking for help.

I need a macro to help me empty out cells that are supposed to be blank.
Some of the blank cells have spaces or invisible data in them (what i mean is there no databut they don't register as "" when i do my formulas)
So what i'm hoping for is some way to have a macro make all cells that have a space but nothing else in them empty.
please help if you can.

Thanks
Tony
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
6,765
Office Version
  1. 365
Platform
  1. Windows
Code:
Option Explicit


Sub Clean()
Dim c As Range, rng As Range
Set rng = Range("A1:B10") 'Set your own range
For Each c In rng
c = Trim(c)
Next c
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
68,027
Office Version
  1. 365
Platform
  1. Windows
If you put this in an unused cell & point it to one of the "blank" cells, what does it say?
=CODE(a1)
 

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,976
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Fluff,
it came back with 160
Thanks
Tony
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
68,027
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

In that case try
Rich (BB code):
Sub tonywatson()
   ActiveSheet.UsedRange.Replace Chr(160), "", xlWhole, , , , False, False
End Sub
 

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,976
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Thank you Fluff,
Seams to hsve done the job nicely :)
Tony
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
68,027
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,972
Messages
5,767,400
Members
425,410
Latest member
SmittyT

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
Top