Evaluating Range for NULL or "" and replacing with .Clear

VenturSum

Board Regular
Joined
May 23, 2010
Messages
138
Programmers,

My imported dataset has null values.

Currently I loop through the columns and rows; and use this is code:

IF .CELL(lRow, lCol).Value = "" THEN .CELL(lRow,lCol).Clear

This method takes a long time.

Could the .Range &/or Evalute method be used?

Something like:
With Range("A1", "Z"&lRowLast)
.CLEAR IF ISNULL
End With


Any thoughts?

Respectfully,

John In Annapolis.
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
If they are nullstrings try
Code:
With ActiveSheet.UsedRange
   .Value = .Value
End With
If not select a cell that you want to clear & run this
Code:
MsgBox Asc(ActiveCell)
What does the message box say?
 
Upvote 0
If you don't have your heart set on VBA,

Select the column(s) of interest

Do Ctrl+F (Find), leave Find what blank, press Find All

Do Ctrl+A to select all those cells, the either press Delete to clear contents, or Clear > Clear All to clear everything.
 
Upvote 0
Team.

I must use VBA.

Is there a way to use With .Range() or Set Range
to set the cells to .Clear where .Value = ""
?

This method would be much faster than looping thru the columns and rows.

In XML, .Clear removes the cell reference completely,
<v><v>not just emptying the value attribute.


Respectfully,

John in Annapolis, MD</v></v>
 
Last edited:
Upvote 0
Team.

I must use VBA.

Is there a way to use With .Range() or Set Range
to set the cells to .Clear where .Value = ""
?

This method would be much faster than looping thru the columns and rows.
Did you see what Fluff posted in Message #2 ... simply change the object of the With statement to your needed range.
 
Upvote 0
I retract that, you and Fluff are correct.

So ashamed ... :oops:
 
Upvote 0
Team.

I am AMAZED that .Value = .Value clears out the null values.
Even in the XML code, I did not see references to the cells.

This was a great piece of code and really sped up the process.

Thank you,

John, In Annapolis, MD
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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