ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Custom Fields with spaces (https://www.excelbanter.com/excel-programming/393310-custom-fields-spaces.html)

[email protected]

Custom Fields with spaces
 
Hi,
The easiest way to explain my dilemma is by example. I need a custom
field that is always thirty character spaces long no matter how long
the text is. So for example, lets say the word is PIZZA which is 5
characters, I would need 25 blank spaces afterwards to get to 30
characters in total. Does anybody know what this would look like?
I've tried to use the _ but that doesn't seem to work. Thanks.


Jim Thomlinson

Custom Fields with spaces
 
Try something like this...

Sub PadText()
Dim str As String

str = "Pizza"
MsgBox str & "!"
str = str & Space(30 - Len(str))
MsgBox str & "!"
End Sub
--
HTH...

Jim Thomlinson


" wrote:

Hi,
The easiest way to explain my dilemma is by example. I need a custom
field that is always thirty character spaces long no matter how long
the text is. So for example, lets say the word is PIZZA which is 5
characters, I would need 25 blank spaces afterwards to get to 30
characters in total. Does anybody know what this would look like?
I've tried to use the _ but that doesn't seem to work. Thanks.



Gary Brown

Custom Fields with spaces
 
If your data is in Cell A1 then...

=LEFT(A1,30)&REPT(" ",30-LEN(LEFT(A1,30)))

--
HTH,
Gary Brown

If this post was helpful to you, please select
''''''''''''''''YES'''''''''''''''' at the bottom of the post.



" wrote:

Hi,
The easiest way to explain my dilemma is by example. I need a custom
field that is always thirty character spaces long no matter how long
the text is. So for example, lets say the word is PIZZA which is 5
characters, I would need 25 blank spaces afterwards to get to 30
characters in total. Does anybody know what this would look like?
I've tried to use the _ but that doesn't seem to work. Thanks.



Dave Peterson

Custom Fields with spaces
 
Check your other posts, too.

wrote:

Hi,
The easiest way to explain my dilemma is by example. I need a custom
field that is always thirty character spaces long no matter how long
the text is. So for example, lets say the word is PIZZA which is 5
characters, I would need 25 blank spaces afterwards to get to 30
characters in total. Does anybody know what this would look like?
I've tried to use the _ but that doesn't seem to work. Thanks.


--

Dave Peterson

[email protected]

Custom Fields with spaces
 
On Jul 13, 12:06 pm, Gary Brown
wrote:
If your data is in Cell A1 then...

=LEFT(A1,30)&REPT(" ",30-LEN(LEFT(A1,30)))

--
HTH,
Gary Brown

If this post was helpful to you, please select
''''''''''''''''YES'''''''''''''''' at the bottom of the post.



" wrote:
Hi,
The easiest way to explain my dilemma is by example. I need a custom
field that is always thirty character spaces long no matter how long
the text is. So for example, lets say the word is PIZZA which is 5
characters, I would need 25 blank spaces afterwards to get to 30
characters in total. Does anybody know what this would look like?
I've tried to use the _ but that doesn't seem to work. Thanks.- Hide quoted text -


- Show quoted text -


Got it thanks for all the help!



All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com