Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default actual value of cell, not reference

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default actual value of cell, not reference

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default actual value of cell, not reference

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is the actual calculation different from actual sample Joe Excel Discussion (Misc queries) 4 May 1st 10 11:46 PM
Show actual values added instead of cell references? (=A1+A4 shows as=10+2 in cell) Naji[_2_] Excel Discussion (Misc queries) 4 December 30th 09 03:03 AM
Show actual values added instead of cell references? (=A1+A4 showsas =10+2 in cell) Naji[_2_] Excel Worksheet Functions 6 December 30th 09 12:39 AM
Go to from reference in VBA code to actual cell? John Dalberg Excel Programming 5 September 16th 06 03:15 PM
& reference answering as Date Serial # not actual text Kevin M Excel Worksheet Functions 0 November 30th 04 05:57 PM


All times are GMT +1. The time now is 11:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"