Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default insert cell value into string

Hello-

I have the code below which is evaluating cell (E6) and entering a
text string in (D15) based on the value. I want to replace the XXX
part of the string with the value of (A6) if each scenario. Any ideas?
Thanks in advance.

Scott

Sub Com1()

Dim myCell As Range
Set myCell = Selection


On Error Resume Next

If Range("E6").Value <= 8 Then
Range("d16").Select
ActiveCell.FormulaR1C1 = "Great job, you handled XXX calls yesterday!"
ElseIf Range("E6").Value <= 8.25 Then
Range("d16").Select
ActiveCell.FormulaR1C1 = "Way to go, your XXX calls really made a
difference!"
ElseIf Range("E6").Value <= 8.5 Then
Range("d16").Select
ActiveCell.FormulaR1C1 = "Wow, XXX calls in one day is fantastic!"

End If
myCell.Select
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default insert cell value into string

i would add these 2 lines:

dim ws as worksheet
set ws = worksheets("Sheet1")

then
ActiveCell.Value = "Wow, " & ws.Range("A1").Value & "calls in one day is
fantastic!"


--


Gary


"Scott" wrote in message
...
Hello-

I have the code below which is evaluating cell (E6) and entering a
text string in (D15) based on the value. I want to replace the XXX
part of the string with the value of (A6) if each scenario. Any ideas?
Thanks in advance.

Scott

Sub Com1()

Dim myCell As Range
Set myCell = Selection


On Error Resume Next

If Range("E6").Value <= 8 Then
Range("d16").Select
ActiveCell.FormulaR1C1 = "Great job, you handled XXX calls yesterday!"
ElseIf Range("E6").Value <= 8.25 Then
Range("d16").Select
ActiveCell.FormulaR1C1 = "Way to go, your XXX calls really made a
difference!"
ElseIf Range("E6").Value <= 8.5 Then
Range("d16").Select
ActiveCell.FormulaR1C1 = "Wow, XXX calls in one day is fantastic!"

End If
myCell.Select
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default insert cell value into string

Gary Keramidas schrieb:

ActiveCell.Value = "Wow, " & ws.Range("A1").Value & "calls in one day is
fantastic!"


I think it's better to use this code:

ActiveCell.Value = "Wow, " + ws.Range("A1").Text + "calls in one day _
is fantastic!"

AFAIR is '&' the operator for 'Binary AND'. To concat strings in VBA,
you need the '+' operator.

And I found that using the .text property of a range saves you some
hassle, if the content of the cell can be interpreted as something other
than a string.

CU,
Christian
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
Insert Cell Data Into String sheller2346 Excel Worksheet Functions 2 July 7th 10 08:17 PM
Insert characters into String franciz Excel Programming 4 May 11th 08 07:54 AM
Need macro to insert text string while inside cell (formula) BrianB Excel Discussion (Misc queries) 0 May 31st 05 03:18 PM
Does Alt-Enter insert a non-printing character in a cell string? Henry Stock Excel Programming 3 February 23rd 05 09:28 PM
How to insert: " into a string Torben Laursen Excel Programming 3 November 10th 04 09:18 AM


All times are GMT +1. The time now is 08:24 AM.

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"