![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi
I know that you can, for instance, make part of a sentence bold while not affecting the original formatting of the rest in Excel. My question for you is this: I am entering a string into one cell via VBA. Is there any way, using code, to format a selective part of any string. Just in case I'm not clear, please see the example below: MyString = "A walk in the park" Would it be possible to send this string with 'park' having a larger font than the rest of the string? If I cannot store this in a string, is there another way? Thanks! Tom [ This Message was edited by: TsTom on 2002-03-23 08:14 ] |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi Tom,
Changed the subject header, I see. I came back to the board and couldn't find the post at first. The following routine searches the text and doubles the size of 'park' on the worksheet cell. The text is hardoced in the routine, but you can generalize this. No error handling is included. ---begin VBA--- Sub Partial_Cell_Text() Dim MyString As String, FindString As String Dim MyPosition As Integer MyString = "A walk in the park." FindString = "park" With Range("A1") .Value = MyString MyPosition = WorksheetFunction.Find(FindString, MyString, 1) With .Characters(Start:=MyPosition, Length:=Len(FindString)).Font .Size = .Size * 2 End With End With End Sub ---end VBA--- HTH, Jay |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Thanks Jay!
I appreciate very much! |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|