Clear nulls cells in a range so they are blank

ChristineJ

Well-known Member
Joined
May 18, 2009
Messages
768
Office Version
  1. 365
Platform
  1. Windows
This code clears the cells on a sheet that have a value of "" (null) so that they are blank.
Code:
Sub Macro2()
With ActiveSheet
   .UsedRange.Value = Evaluate("IF(ROW(" & .UsedRange.Address & "),CLEAN(" & .UsedRange.Address & "))")
End With
End Sub

Is there a way to do the same thing for a range of cells on a sheet rather than on the entire sheet? I am hoping for a way that does not involve looping from one row to the next, which takes a long time.

Thanks
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Are the "" as the result of a formula that has been cut/pasted as values?
 
Upvote 0
Not necessarily cut and paste, and not necessarily values.

Could just be a formula right within the cell, such as if(G1=5,"",100) where G1 does equal 5.

Just want to convert a null to a blank. Sorry to have been unclear.
 
Upvote 0
You do realise that your code will remove the formulae from the cells?
Is that what you want?
 
Upvote 0
You do realise that your code will remove the formulae from the cells?
Is that what you want?
Yes, that is what I want - for the cells in a specified range (such as A1:A2000, for example) to be cleared so they are completely blank.

(The code I posted clears all the cells on the sheet - not what I need - but it seems to do it fast without looping.) Thanks again.
 
Upvote 0
In that case you can use
VBA Code:
With ActiveSheet.Range("A1:A20")
   .Value = .Value
End With
 
Upvote 0
Solution
Yes, that does it, and quickly! I appreciate your help so much. C
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,968
Messages
6,133,788
Members
449,832
Latest member
drollins

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