LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Multiple Formats In The Same Cell

Another one -

Sub test2()
Dim pos1 As Long, pos2 As Long
Dim rng As Range, cel As Range
' all Arial
' LLL+MMM-RRR
' LLL blue, bold-true 10
' MMM red, bold-false,8
' RRR and +/- auto/black, bold-false, 8

On Error Resume Next

Set rng = Range("D:H").SpecialCells(xlCellTypeConstants, 2)
If rng Is Nothing Then Exit Sub

If rng.Count 10 Then
Application.ScreenUpdating = False
End If

For Each cel In rng

pos1 = InStr(2, cel, "+")
pos2 = InStr(pos1 + 1, cel, "-")

If pos1 Or pos2 Then
With cel.Font
.Name = "Arial"
.Size = 8
.ColorIndex = xlAutomatic
.Bold = False
End With
End If

If pos1 Then
With cel.Characters(1, pos1 - 1).Font
.Size = 10
.ColorIndex = 5
'' if possibility of non default palette use
' .Color = &HFF0000
.Bold = True
End With
End If

If pos2 1 Then
cel.Characters(pos1 + 1, pos2 - pos1 - 1).Font.ColorIndex = 3
' or .Color = &HFF
End If
Next

If Application.ScreenUpdating = False Then
Application.ScreenUpdating = True
End If

End Sub

Regards,
Peter T

"nospaminlich" wrote in message
...
Good evening

I have data in various cells in columns D to H in a spreadsheet. Where
there is data it is in 3 parts separated by a "+" and "-".

I want to write a macro which scrolls down and in each cell where there is
data I want to format everything to the left of the "+" Bold, Arial 10,

Blue,
everything to the right of the - Arial 8, Black and everything between the
"+" and the "-" Arial 8, Red.

Whilst it is possible to manually format each cell I haven't been able to
make Conditional Formatting work with this but that could be because I had
the syntax of the formula wrong.

Is it possible to achieve this with a macro and if so please can I have

some
help with the code.

Many thanks in anticipation

Kewa



 
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
Multiple formats in a cell Gridlock Excel Worksheet Functions 2 November 18th 09 09:45 AM
multiple formats in a cell Gridlock Excel Worksheet Functions 2 November 17th 09 02:04 PM
Multiple formats in a single cell with multiple formulas Zakhary Excel Worksheet Functions 1 May 2nd 08 12:08 AM
Multiple formats in the same cell [email protected] Excel Worksheet Functions 2 January 16th 07 11:49 PM
Multiple formats within a cell gailann Excel Discussion (Misc queries) 5 June 7th 06 03:42 PM


All times are GMT +1. The time now is 01:37 PM.

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"