Phone book formatting

J

Jim Berglund

How do I create a format that will insert the appropriate number of dots
between the name and the phone number so that I'll have the name
left-aligned and the phone number right-aligned, as in the folllowing
example:

Anthony Hopkins............942-4567 (35 characters)

Thanks,
Jim Berglund
 
O

Office_Novice

A few questions...

1) How is the name entered manually of progammaticly
2) specific Range or no?
3)How is the phone number entered?
 
J

Jim Thomlinson

Is this all supposed to be in 1 cell? Is the source data in seperate cells?
Is it always supposed to be 35 characters in length which implies you are
using a non-proportional font like courier?
 
D

Dave Peterson

If you're doing this to create a mini-phonebook, you may find that you have lots
more formatting choices if you did it in MSWord.
 
O

Office_Novice

Assuming Names and phone number a entered manually try this

Option Explicit

Sub AddDots()
Dim Rng As Range
Dim i As Variant

Set Rng = Range("A1:A65536")
i = Cells

For Each i In Rng
i.Offset(1, 0).Select
If i.Value <> "" Then
i.Offset(0, 1).Select
ActiveCell.Value = "..................................."
ElseIf i.Value = "" Then
End If
Next
End Sub
 
J

Joel

I would add another columns with the dots. Then use a formula like this

=Rept(".",35 - len(A10))

where A10 is the cell wi the person name. Rept will repeat the dot x number
of times.
 
J

Jim Thomlinson

Note that that solution only works with a non-propotional font like courier.
With Arial and other proportional fonts each character is a different width
and 35 characters will take up different amount so space.
 
J

Jim Berglund

Thanks, all of you.
I liked Joel's response, best - short, easy, and it works!
Jim
 
D

Dave Peterson

I don't know.

Using MSWord is pretty simple for tables like this. Changing the formatting for
the tab character is pretty simple, too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top