Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-02-2014, 07:50 PM
fumei fumei is offline Add asterisks in front of all bold sentences in a table cell Windows 7 64bit Add asterisks in front of all bold sentences in a table cell Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Please use code tags when posting codes.
Quote:
so I don't want to use range and move from cell to cell because it ignores the other sentences.
No, you DO want to use range, because it does NOT ignore other sentences.
Code:
Sub AsterisksBold()
Dim r As Range
Dim SentenceRange As Range
Set r = Selection.Range.Cells(1).Range
For Each SentenceRange In r.Sentences
  If SentenceRange.Font.Bold = True Then
     SentenceRange.InsertBefore "**"
  End If
Next
End Sub
Assuming of course you really do mean sentences, not paragraphs.

Oh, and the above REQUIRES that the selection is in the cells that you want to act. It will fail if the selection is not in a table. Best practice would actually test to make sure it IS in a table first. I did not bother...you should do it though.
Reply With Quote
 

Tags
macro table search



Similar Threads
Thread Thread Starter Forum Replies Last Post
Add asterisks in front of all bold sentences in a table cell Keep box drawn in front of Video in FRONT position a_gunslinger PowerPoint 1 04-18-2013 07:54 AM
Format Bold in one line makes all lines bold Nitte Word 2 02-07-2013 12:34 AM
asterisks turned into broken line -- can't get rid of gsjackson Word 3 12-02-2011 03:14 PM
Table of Authorities Entries - Zombie Bold emilypage Word 2 10-25-2011 06:56 AM
Auto-populate an MS Word table cell with text from a diff cell? dreamrthts Word Tables 0 03-20-2009 01:49 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:12 PM.


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