Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -- Gary "alistre" wrote in message oups.com... 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -- Cheers Nigel "alistre" wrote in message oups.com... 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Forgot to mention - change the Sheet1 reference as required, in your case
this would be..... With Sheets("Regional Banks") not With Sheets("Sheet1") -- Cheers Nigel "Nigel" wrote in message ... 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 -- Cheers Nigel "alistre" wrote in message oups.com... 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Worked like a charm. You're a genious.
Nigel wrote 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 -- Cheers Nigel "alistre" wrote in message oups.com... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I resort numerical info into numerical order | Excel Worksheet Functions | |||
Clearing cells without clearing formulas | Excel Discussion (Misc queries) | |||
Clearing A Row | Excel Programming | |||
Clearing #N/A's in one go? | Excel Worksheet Functions | |||
Clearing #VALUE | Excel Worksheet Functions |