#1   Report Post  
Posted to microsoft.public.word.docmanagement
Help on formula Help on formula is offline
external usenet poster
 
Posts: 9
Default Is it possible?

I have two columns of names A and B (A=First name B=Last name). My question
is, without changing the column A and B, how could be the Macro defined so
that column As or Bs characters are if less than four, the comas (,)
inserts into to make it four i.e. €śLeo=LEO,€ť €śA=A,,,€ť. Blank fields should
stay blank and if its possible if the small letters of name in column A or B
can also be capitalized in the same Macro. To explore the possibilities I
thanks in advance€¦

Sincerely Shan

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Is it possible?

I take it that you want to change the entries in the table to add commas as
appropriate and format as upper case? Then assuming the first table in the
document and the first two columns of that table, the following will do
that.

Sub AddCommas()
Dim oTable As Table
Dim oRng As Range
Dim i As Long, j As Long, k As Long
Set oTable = ActiveDocument.Tables(1)
For i = 1 To oTable.Rows.Count
For j = 1 To 2
Set oRng = oTable.Cell(i, j).Range
oRng.End = oRng.End - 1
If Len(oRng) 4 Then
For k = 1 To 4 - Len(oRng)
oRng.InsertAfter ","
Next k
End If
Next j
Next i
End Sub

http://www.gmayor.com/installing_macro.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Help on formula wrote:
I have two columns of names A and B (A=First name B=Last name). My
question is, without changing the column A and B, how could be the
Macro defined so that column A's or B's characters are if less than
four, the comas (,) inserts into to make it four i.e. "Leo=LEO,"
"A=A,,,". Blank fields should stay blank and if it's possible if the
small letters of name in column A or B can also be capitalized in the
same Macro. To explore the possibilities I thanks in advance.

Sincerely Shan



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:58 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"