Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default format a specific letter by code

I guess to make sense as a macro, I should assume the two names are in
adjacent columns (my original code assumed the text was already concatenated
on the DataSheet). This macro will start by taking the names from the
StartDataCell and the cell to its right, concatenate them, then put that
concatenated text on the CopySheet starting in the StartCopyCell and then
continue doing that on down the two columns on the DataSheet...

Sub CopyDataHighlightV()
Dim TextToCopy As String
Dim X As Long, Vposition As Long, StartRow As Long, LastRow As Long
Const DataSheet As String = "Sheet1"
Const StartDataCell As String = "D9"
Const CopySheet As String = "Sheet2"
Const StartCopyCell As String = "C3"
'....
'....
With Worksheets(DataSheet).Range(StartDataCell)
StartRow = .Row
LastRow = .End(xlDown).Row
For X = 0 To LastRow - StartRow
TextToCopy = .Offset(X).Value & " v " & .Offset(X, 1).Value
Vposition = Len(.Offset(X).Value) + 1
With Worksheets(CopySheet).Range(StartCopyCell).Offset( X)
.Value = TextToCopy
With .Characters(Vposition + 1, 1).Font
.Bold = True
.ColorIndex = 3
End With
End With
Next
End With
End Sub

--
Rick (MVP - Excel)



"Rick Rothstein" wrote in message
...
You left a lot of detail out, so I constructed a general "copy data,
format the v" macro for you to use, just change the values in the four
Const statements to match your actual setup...

Sub CopyDataHighlightV()
Dim TextToCopy As String
Dim X As Long, Vposition As Long, StartRow As Long, LastRow As Long
Const DataSheet As String = "Sheet1"
Const StartDataCell As String = "A1"
Const CopySheet As String = "Sheet2"
Const StartCopyCell As String = "B2"
'....
'....
With Worksheets(DataSheet).Range(StartDataCell)
StartRow = .Row
LastRow = .End(xlDown).Row
For X = 0 To LastRow - StartRow
TextToCopy = .Offset(X).Value
Vposition = InStr(TextToCopy, " v ")
With Worksheets(CopySheet).Range(StartCopyCell).Offset( X)
.Value = TextToCopy
With .Characters(Vposition + 1, 1).Font
.Bold = True
.ColorIndex = 3
End With
End With
Next
End With
End Sub

--
Rick (MVP - Excel)



"Jock" wrote in message
...
Hi there,
when text is copied to a new sheet by code, I need a specific letter (v)
made bold and red to indicate to the user that the words on either side
of it
are seperate.
A good analogy would be football teams, so for instance:
Real Madrid v Real Betis. Here the 'v' between the names would be red and
bold.
Valencia v Villa Real. I only want the 'v' seperating the team names to
be
formatted as above.
Any ideas?
Thanks.
--
Traa Dy Liooar

Jock


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
how to recognize a specific letter in a cell Ksenija Excel Programming 1 January 19th 09 11:04 AM
go to a specific letter in a list Petya Excel Worksheet Functions 4 February 15th 07 04:05 PM
go to a specific letter in a list Toppers Excel Worksheet Functions 0 February 15th 07 03:18 PM
go to a specific letter in a list Petya Excel Worksheet Functions 0 February 15th 07 03:13 PM
New Validation option to format 1st letter as Capital letter Jeff Excel Discussion (Misc queries) 5 July 13th 06 05:11 AM


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