PC Review


Reply
Thread Tools Rate Thread

Adding text to Formula result in VBA?

 
 
Mike Proffit
Guest
Posts: n/a
 
      20th Apr 2007
Hi all. I've got a vlookup formula on a spreadsheet with relative cell addressing that my macro copies when appropriate. I want to retain that formula but concatenate " For Serial Number 12345" so that appears in the cell.

sSerialNum is the variable. Here's my (failing) approach:

If Left(items(j), 3) = "UPG" Then
sForsn = " For Serial Number " & sSerialNum
ActiveCell.Offset(0, 4).Formula = ActiveCell.Offset(0, 4).Formula _
& " & "" & sForsn & """
End If

This results in the formula
=VLOOKUP(C30,PriceMatrix,2,0)) & " & sForsn & "

which tacks on '& sForsn &' after the successful lookup of the value. Of course, I want "For Serial Number 12345" to be there instead.

Any help... much thanks!
Mike

 
Reply With Quote
 
 
 
 
JE McGimpsey
Guest
Posts: n/a
 
      20th Apr 2007
Quote marks need to be doubled. One way:

If Left(items(j), 3) = "UPG" Then
sForsn = " For Serial Number " & sSerialNum
With ActiveCell.Offset(0, 4)
.Formula = .Formula & " & """ & sForsn & """"
End With
End If


In article <(E-Mail Removed)>,
"Mike Proffit" <(E-Mail Removed)> wrote:

> Hi all. I've got a vlookup formula on a spreadsheet with relative cell
> addressing that my macro copies when appropriate. I want to retain that
> formula but concatenate " For Serial Number 12345" so that appears in the
> cell.
>
> sSerialNum is the variable. Here's my (failing) approach:
>
> If Left(items(j), 3) = "UPG" Then
> sForsn = " For Serial Number " & sSerialNum
> ActiveCell.Offset(0, 4).Formula = ActiveCell.Offset(0, 4).Formula _
> & " & "" & sForsn & """
> End If
>
> This results in the formula
> =VLOOKUP(C30,PriceMatrix,2,0)) & " & sForsn & "
>
> which tacks on '& sForsn &' after the successful lookup of the value. Of
> course, I want "For Serial Number 12345" to be there instead.
>
> Any help... much thanks!
> Mike

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking up Text as a result of a formula Hammer Microsoft Excel Worksheet Functions 1 16th Nov 2009 10:21 PM
The result of a formula referring to a cell with formula as text? JCC Microsoft Excel Worksheet Functions 10 3rd Sep 2009 03:15 PM
copy formula result (text) only - without copying formula Mulberry Microsoft Excel Misc 2 2nd Oct 2008 09:51 AM
formula is displayed as literal text instead of formula result carlossaltz Microsoft Excel Misc 2 1st Jul 2005 09:26 PM
Adding text to the result of a formula? Robbie in Houston Microsoft Excel Worksheet Functions 2 28th Feb 2005 12:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:54 AM.