Clearing content where formula returns blank value

Declamatory

Active Member
Joined
Nov 6, 2014
Messages
319
Good afternoon,

I have a workbook that has 7 sheets. The first three sheets named Order, Order Allocation and Order Allocation Charge. There is data in these three sheets that use formulas to look at data in the last four sheets to create orders that are to imported to our operating system. The import fails if a formula returns a blank value e.g. there are 10 orders but row 11 is blank (but contains formulas).

We would not have more than 200 orders in a day.

Is there a way of using vba to clear the contents of cells A1:R200 where the value is blank?

I found this on the web and it does work but only does one column.

Sub ClearCell()
Dim Rng As Range
Set Rng = ActiveSheet.Range("A1")

Dim i As Long
For i = 1 To 200
If Rng.Cells(i, 1) = "" Then
Rng.Cells(i, 1).ClearContents
End If
Next i
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
How about
VBA Code:
Sub Declamatory()
   Dim Cl As Range
   
   For Each Cl In ActiveSheet.UsedRange.SpecialCells(xlFormulas, xlTextValues)
      If Cl.Value = "" Then Cl.ClearContents
   Next Cl
End Sub
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,500
Members
449,090
Latest member
RandomExceller01

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