Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code to fill rest of cell with dashes (-)


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


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=571986

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default VBA code to fill rest of cell with dashes (-)

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

mikeburg wrote:
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


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=571986


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA code to fill rest of cell with dashes (-)


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


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=571986

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
Look up field and auto fill the rest [email protected] Excel Worksheet Functions 4 April 2nd 09 04:55 PM
Addind cell together with a rest. Rodger Excel Discussion (Misc queries) 7 February 21st 07 01:32 AM
Trying to find a way to fill in the rest of a row if it is a dupli Robert Brown Excel Worksheet Functions 2 June 29th 06 05:58 PM
Can I auto fill a cell in one worksheet by typing a code number Gomer Pyle Excel Worksheet Functions 1 August 27th 05 01:24 AM
Fill-In Rest Of Column Bob Barnes Excel Programming 4 September 6th 04 03:01 PM


All times are GMT +1. The time now is 12:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"