vba to clear negative numbers to

BORUCH

Well-known Member
Joined
Mar 1, 2016
Messages
528
Office Version
  1. 365
Platform
  1. Windows
hi

i have the below code

VBA Code:
Sub clearcrfromcell()
  Dim Num As String, V As Variant, Rng As Range
  Num = InputBox("What number do you want to clear?")
  For Each V In Split(Num, "-")
    Columns("D").Replace V, "", xlWhole, , , , False, False
    On Error Resume Next
    For Each Rng In Columns("D").SpecialCells(xlBlanks).Areas
      Rng.Offset(, 1).Formula = "=" & Rng.Offset(, -1).Address(0, 0)
      Rng.Value = 0
    Next
  Next
end sub

for some reason its not clearing numbers that are negative i would like it to clear both

thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
That's because you are using the minus sign as separator, here: Split(Num, "-")
The macro allows you to enter multiple numbers at the same time in the input box separated by the minus sign.
Use instead a comma as separator if it isn't the decimal separator in your language, elsewise use other character like ; or : .
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,973
Messages
6,122,534
Members
449,088
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