Clearing Non-numerical CellCvalues

  • Thread starter Thread starter alistre
  • Start date Start date
A

alistre

Hello, I have a range (D9:DP496) that contains numerical values and
text. I want to clear all the cells that do not have numerical values.
I attempted it below but failed miserably. As you can see I am a new
learner to VBA. Can you help?

If Workbooks("Regional Banks.xls").Worksheets("Regional
Banks").Range("D9:DP496") <> Format ("#") Then Cells.Value = ""
End If
 
try this and see if it works for you


Sub test()
Dim cell As Range
For Each cell In Range("D9:DP496")
If IsNumeric(cell.Value) Then
cell.Value = cell.Value
Else
cell.Value = ""
End If
Next
End Sub
 
This should work.......

Sub ClearArea()
Dim Cell As Range
Application.ScreenUpdating = False

With Sheets("Sheet1")
For Each Cell In .Range("D9:DP496")
If Not IsNumeric(Cell.Value) Then Cell.Value = ""
Next
End With

Application.ScreenUpdating = True
End Sub
 
Forgot to mention - change the Sheet1 reference as required, in your case
this would be.....

With Sheets("Regional Banks") not With Sheets("Sheet1")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top