Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-26-2022, 06:20 AM
abonsey abonsey is offline replace cell text results in extra carriage return Windows 11 replace cell text results in extra carriage return Office 2021
Novice
replace cell text results in extra carriage return
 
Join Date: May 2022
Posts: 6
abonsey is on a distinguished road
Default replace cell text results in extra carriage return


I have a snippet of vba to insert a mixture of variable, other cell values and static text into a new cell

Looking at the code below the result is the variable 'FullBoxes' and the contents from 'ActiveDocument.Tables(1).Cell(1, 3).Range' are on one line but the wording "containing" begins on another line.

What causes that and how do I stop what is effectively a carriage return being applied.

TIA

With ActiveDocument.Tables(1).Cell(i, 3).Range
.Font.Name = "Arial"
.Font.Size = 10
If Remaining > 0 Then
.Text = FullBoxes & " " & ActiveDocument.Tables(1).Cell(1, 3).Range & " containing "
Reply With Quote
  #2  
Old 05-26-2022, 08:22 AM
macropod's Avatar
macropod macropod is offline replace cell text results in extra carriage return Windows 10 replace cell text results in extra carriage return Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That's because a cell's range includes the end-of-cell marker - which ordinarily looks like the '¤' symbol.

One approach would be to use:
Code:
Text = FullBoxes & " " & Split(ActiveDocument.Tables(1).Cell(1, 3).Range.Text, vbCr)(0) & " containing "
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-27-2022, 02:55 AM
abonsey abonsey is offline replace cell text results in extra carriage return Windows 11 replace cell text results in extra carriage return Office 2021
Novice
replace cell text results in extra carriage return
 
Join Date: May 2022
Posts: 6
abonsey is on a distinguished road
Thumbs up

Thanks. That worked Brilliantly
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to split values from carriage-return from the cell ganesang Excel 3 12-02-2019 07:16 AM
replace cell text results in extra carriage return Find / Replace hard Carriage Return with Line break. GreenBoy Word 2 03-11-2018 02:32 AM
carriage return on PPT yangthomson PowerPoint 0 04-21-2016 07:16 PM
Adding a carriage return at end of each line, and then a blank space, after text entry complete CEMurphy4 Word VBA 1 12-02-2015 11:53 PM
Plain Text Content Control - Losing Styling on Carriage Return kintap Word 0 07-16-2014 12:43 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:56 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft