Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula does not recognize concatenated value

Status
Not open for further replies.

str8up4u

Programmer
Aug 26, 2003
3
US
I used a formula to concatenate 2 values, copied the results and pasted the values. Using another formula on the results , it does not recognize the pasted values, returning inaccurate results.

Sub Macro1()
'
Range("H51").Select
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(COUNTIF(R[-49]C[-6]:R[-1]C[-2],RC[-1]),(COUNTIF(R[-11]C[-6]:RC[-6],RC[-1])))"
Range("H51").Select
Selection.AutoFill Destination:=Range("H51:H84"), Type:=xlFillCopy
Range("H51:H84").Select
Selection.Copy
Range("H51").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub

This would give me values such as 113, 92, 80, 51, etc.
Using the following formula only produced inaccurate results.

Sub Macro7()
'
Range("I51").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = &quot;=IF(RC[-1]>88,&quot;&quot;X&quot;&quot;,IF(RC[-1]<60,&quot;&quot;Y&quot;&quot;,RC[-1]))&quot;
Range(&quot;I51&quot;).Select
Selection.AutoFill Destination:=Range(&quot;I51:I84&quot;), Type:=xlFillCopy
Range(&quot;I51:I84&quot;).Select

End Sub

After running this macro, all the results were &quot;X&quot; regardless whether the value was >88 or <60. I tried changing the format of the values to numbers, text and general with the same results. What am I doing wrong?

Also, the relative reference toolbar that pops-up when you record a macro no longer appears when I record a macro and the code is written as relative reference. I've tried rebooting, no results, still not available. I'm using Excel XP. Any suggestions?

 
Hah! I solved my own problem. I added the Value function to the cell address.

ActiveCell.FormulaR1C1 = &quot;=IF(Value(RC[-1])>88,&quot;&quot;X&quot;&quot;,IF(Value(RC[-1])<60,&quot;&quot;Y&quot;&quot;,RC[-1]))&quot;

Bingo! Works out perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top