VBA code to fill rest of cell with dashes (-)

M

mikeburg

I have a user defined function called NumWord that converts a number in
a cell to the words for the number.

I want to be able to run a macro that will take the value in G4,
convert it to words for the number, & add enough dashes to fill the
rest of cell & put it in cell H5 which is formatted to Text & 41
characters wide with left aligned. Since the font used is Ariel, there
will be no fixed number of characters that will fill the cell.

My vba code so far is:
ACheckWrittenAmt = NumWord(Range("G4"))
Range("H5") = ACheckWrittenAmt

Example: I need the VBA code to put the following in cell H5 for 43.00
in G4

Fourty Three and 00/100----------------------


or put the following in cell H5 for 251.52 in G4

Two Hundred Fifty One and 52/100------------

Any VBA code suggestions will be greatly appreciated! Thanks a bunch.
mikeburg
 
D

Die_Another_Day

Try using this to get close:
Sub FillCell()
Dim str1 As String
Dim MikesString as String
MikesString = "Fourty Three and 00/100"
str1 = Space(41) 'Sets str1 to 41 consecutive spaces
str1 = Replace(str1, " ", "-", 1) 'Replaces the 41 consecutive spaces
with dashes
str1 = Left(MikesString & str1, 41)
'Give the leftmost 41 characters of the
'Variable "MikesString" and 41 consecutive dashes
MsgBox str1
End Sub

HTH

Charles Chickering
 
M

mikeburg

Thanks a million. I don't know how I will ever learn this VBA without
all you guys helping! mikeburg
 

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