Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Adding text to Formula result in VBA?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Adding text to Formula result in VBA?

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 ,
"Mike Proffit" 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
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
The result of a formula referring to a cell with formula as text? JCC Excel Worksheet Functions 10 September 3rd 09 03:15 PM
copy formula result (text) only - without copying formula Mulberry Excel Discussion (Misc queries) 2 October 2nd 08 09:51 AM
Text Result Formula Creolekitten via OfficeKB.com Excel Discussion (Misc queries) 5 July 24th 06 09:32 PM
formula is displayed as literal text instead of formula result carlossaltz Excel Discussion (Misc queries) 2 July 1st 05 09:26 PM
Adding text to the result of a formula? Robbie in Houston Excel Worksheet Functions 2 February 28th 05 12:00 AM


All times are GMT +1. The time now is 06:57 AM.

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

About Us

"It's about Microsoft Excel"