Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 |