ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert leading spaces (https://www.excelbanter.com/excel-programming/349928-insert-leading-spaces.html)

DejaVu[_59_]

Insert leading spaces
 

I have a userform in which the user inputs *Miles Traveled* into two
text boxes -(max & min)-. The miles can be up to 5 characters (99999)
in length.

If the user, for example, enters "_1_" - "_500_"; I want that to be
converted to "_____1_" - "___500_".

I want all the leading characters to be spaces.
Hopefully this makes sense to someone!

TIA

DejaVu


--
DejaVu
------------------------------------------------------------------------
DejaVu's Profile: http://www.excelforum.com/member.php...o&userid=22629
View this thread: http://www.excelforum.com/showthread...hreadid=499477


Dave Peterson

Insert leading spaces
 
Something like:

Option Explicit
Private Sub CommandButton1_Click()

Me.TextBox3.Value _
= Right(Space(5) & CLng(Me.TextBox1.Value), 5) _
& " - " _
& Right(Space(5) & CLng(Me.TextBox1.Value), 5)

End Sub

DejaVu wrote:

I have a userform in which the user inputs *Miles Traveled* into two
text boxes -(max & min)-. The miles can be up to 5 characters (99999)
in length.

If the user, for example, enters "_1_" - "_500_"; I want that to be
converted to "_____1_" - "___500_".

I want all the leading characters to be spaces.
Hopefully this makes sense to someone!

TIA

DejaVu

--
DejaVu
------------------------------------------------------------------------
DejaVu's Profile: http://www.excelforum.com/member.php...o&userid=22629
View this thread: http://www.excelforum.com/showthread...hreadid=499477


--

Dave Peterson

DejaVu[_60_]

Insert leading spaces
 

Dave Peterson - Thanks for the help. That is exactly what I need. It
worked perfectly.

Thanks,

DejaVu


--
DejaVu
------------------------------------------------------------------------
DejaVu's Profile: http://www.excelforum.com/member.php...o&userid=22629
View this thread: http://www.excelforum.com/showthread...hreadid=499477



All times are GMT +1. The time now is 09:21 AM.

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