Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Text String (Edit w/Carriage Return)

I have a string of text in a single cell.

I need a macro to add the following to the end of the string:
1) word "(STOP)" and then ALT Enter {key stoke} to add carriage return.

ISSUE: The macro below adds the word "(STOP)" at the end of the string ,
but I need it to also add a "carriage retun" at the end of the string.

Sub EDIT()
'
' EDIT Macro
'
' this macro creates a name "stop" at the current cell location and then
copies the contents to a range name "copyto". At the stop location the macro
ref to "copyto" and then joins it with "(stop)" and finishes with paste
special values. NEED to add "Carriage Return" to this macro.
'
ActiveWorkbook.Names("stop").Delete
ActiveWorkbook.Names.Add Name:="STOP", RefersToR1C1:=ActiveCell
' "=Sheet1!R5C5"
Selection.Copy
Application.Goto Reference:="copyto"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.Goto Reference:="STOP"
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=copyto&"" (STOP)"""
Range("STOP").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Text String (Edit w/Carriage Return)

Change
ActiveCell.FormulaR1C1 = "=copyto&"" (STOP)"""
to
ActiveCell.FormulaR1C1 = "=copyto&"" (STOP)""" & vbLf

Hope this helps,

Hutch

"lightjag" wrote:

I have a string of text in a single cell.

I need a macro to add the following to the end of the string:
1) word "(STOP)" and then ALT Enter {key stoke} to add carriage return.

ISSUE: The macro below adds the word "(STOP)" at the end of the string ,
but I need it to also add a "carriage retun" at the end of the string.

Sub EDIT()
'
' EDIT Macro
'
' this macro creates a name "stop" at the current cell location and then
copies the contents to a range name "copyto". At the stop location the macro
ref to "copyto" and then joins it with "(stop)" and finishes with paste
special values. NEED to add "Carriage Return" to this macro.
'
ActiveWorkbook.Names("stop").Delete
ActiveWorkbook.Names.Add Name:="STOP", RefersToR1C1:=ActiveCell
' "=Sheet1!R5C5"
Selection.Copy
Application.Goto Reference:="copyto"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.Goto Reference:="STOP"
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=copyto&"" (STOP)"""
Range("STOP").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Text String (Edit w/Carriage Return)

Tom,

I could not get &vbLF to work so I got the desired result by ref a cell ,
named "return" with "STOP and ALTENTER {key stroke}, with:

ActiveCell.FormulaR1C1 = "=copyto&RETURN"

Also the cells I am applying this macro to already are pre-formated for text
wrap.

"Tom Hutchins" wrote:

Change
ActiveCell.FormulaR1C1 = "=copyto&"" (STOP)"""
to
ActiveCell.FormulaR1C1 = "=copyto&"" (STOP)""" & vbLf

Hope this helps,

Hutch

"lightjag" wrote:

I have a string of text in a single cell.

I need a macro to add the following to the end of the string:
1) word "(STOP)" and then ALT Enter {key stoke} to add carriage return.

ISSUE: The macro below adds the word "(STOP)" at the end of the string ,
but I need it to also add a "carriage retun" at the end of the string.

Sub EDIT()
'
' EDIT Macro
'
' this macro creates a name "stop" at the current cell location and then
copies the contents to a range name "copyto". At the stop location the macro
ref to "copyto" and then joins it with "(stop)" and finishes with paste
special values. NEED to add "Carriage Return" to this macro.
'
ActiveWorkbook.Names("stop").Delete
ActiveWorkbook.Names.Add Name:="STOP", RefersToR1C1:=ActiveCell
' "=Sheet1!R5C5"
Selection.Copy
Application.Goto Reference:="copyto"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.Goto Reference:="STOP"
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=copyto&"" (STOP)"""
Range("STOP").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Text String (Edit w/Carriage Return)

ActiveCell.FormulaR1C1 = "=copyto&"" (STOP)""&char(10)"

I don't quite understand what you're doing, but it looks like you're putting the
activecell's value in the cell named copyto.

Then you're taking the value and putting "(stop) & alt-enter" in the activecell.

If that's the case:

Option Explicit
Sub testme01()
With ActiveCell
ActiveWorkbook.Names("CopyTo").RefersToRange.Cells (1).Value = .Value
.Value = .Value & " (STOP)" & vbLf
'.Name = "STOP"
End With
End Sub

There's no reason you need to name the range STOP in this code, but maybe you
use it for something else???

lightjag wrote:

I have a string of text in a single cell.

I need a macro to add the following to the end of the string:
1) word "(STOP)" and then ALT Enter {key stoke} to add carriage return.

ISSUE: The macro below adds the word "(STOP)" at the end of the string ,
but I need it to also add a "carriage retun" at the end of the string.

Sub EDIT()
'
' EDIT Macro
'
' this macro creates a name "stop" at the current cell location and then
copies the contents to a range name "copyto". At the stop location the macro
ref to "copyto" and then joins it with "(stop)" and finishes with paste
special values. NEED to add "Carriage Return" to this macro.
'
ActiveWorkbook.Names("stop").Delete
ActiveWorkbook.Names.Add Name:="STOP", RefersToR1C1:=ActiveCell
' "=Sheet1!R5C5"
Selection.Copy
Application.Goto Reference:="copyto"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.Goto Reference:="STOP"
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=copyto&"" (STOP)"""
Range("STOP").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub


--

Dave Peterson
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
Select text before carriage return jellyroller Excel Discussion (Misc queries) 3 April 26th 23 11:44 AM
Carriage return in a Text box Riddler Excel Programming 2 November 21st 06 08:18 PM
Clear a Carriage Return from a String Value David McRitchie[_2_] Excel Programming 0 August 5th 03 09:54 PM
Clear a Carriage Return from a String Value RC- Excel Programming 0 August 5th 03 09:54 PM
Clear a Carriage Return from a String Value JS[_4_] Excel Programming 0 August 5th 03 09:47 PM


All times are GMT +1. The time now is 03:15 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"