Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro that replaces values below a number set by the user to "ND".
The problem is it doesn't work when the cell contains a reference to another cell or workbook. Is there a way to get the absolute value of the cell and ignore the reference? Here is what I have so far: Sub ND() ' ' Dim rng As Range a = InputBox("Enter a value." & vbNewLine & "Any values below this will be replaced by ND", "ND Replace") If a = "" Or IsNumeric(a) = False Then Exit Sub End If For Each rng In Selection If Val(rng.Value) < a Or rng.Value = "" Then rng.Replace what:=rng.Value, replacement:="ND" End If Next rng End Sub Any help would be appreciated. Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I think your trying to do this Sub ND() Dim rng As Range a = CLng(InputBox("Enter a value." & vbNewLine & _ "Any values below this will be replaced by ND", "ND Replace")) If a = vbNullString Or Not IsNumeric(a) Then Exit Sub End If For Each rng In Selection If rng.Value < a Or rng.Value = "" Then rng.Replace what:=rng.Value, replacement:="ND" End If Next rng End Sub Mike "Labrat" wrote: I have a macro that replaces values below a number set by the user to "ND". The problem is it doesn't work when the cell contains a reference to another cell or workbook. Is there a way to get the absolute value of the cell and ignore the reference? Here is what I have so far: Sub ND() ' ' Dim rng As Range a = InputBox("Enter a value." & vbNewLine & "Any values below this will be replaced by ND", "ND Replace") If a = "" Or IsNumeric(a) = False Then Exit Sub End If For Each rng In Selection If Val(rng.Value) < a Or rng.Value = "" Then rng.Replace what:=rng.Value, replacement:="ND" End If Next rng End Sub Any help would be appreciated. Thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub ND()
' ' Dim rng As Range a = InputBox("Enter a value." & vbNewLine & "Any values below this will be replaced by ND", "ND Replace") If a = "" Or IsNumeric(a) = False Then Exit Sub End If For Each rng In Selection If Val(rng.Value) < a Or rng.Value = "" Then rng.Value ="ND" End If Next rng End Sub -- HTH... Jim Thomlinson "Labrat" wrote: I have a macro that replaces values below a number set by the user to "ND". The problem is it doesn't work when the cell contains a reference to another cell or workbook. Is there a way to get the absolute value of the cell and ignore the reference? Here is what I have so far: Sub ND() ' ' Dim rng As Range a = InputBox("Enter a value." & vbNewLine & "Any values below this will be replaced by ND", "ND Replace") If a = "" Or IsNumeric(a) = False Then Exit Sub End If For Each rng In Selection If Val(rng.Value) < a Or rng.Value = "" Then rng.Replace what:=rng.Value, replacement:="ND" End If Next rng End Sub Any help would be appreciated. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Why is the actual calculation different from actual sample | Excel Discussion (Misc queries) | |||
Show actual values added instead of cell references? (=A1+A4 shows as=10+2 in cell) | Excel Discussion (Misc queries) | |||
Show actual values added instead of cell references? (=A1+A4 showsas =10+2 in cell) | Excel Worksheet Functions | |||
Go to from reference in VBA code to actual cell? | Excel Programming | |||
& reference answering as Date Serial # not actual text | Excel Worksheet Functions |