Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Adding spaces into a variable

I have a problem!

I am writing a macro where the user pastes in a 16 digit number into a
text box on a user form.
This then becomes a variable (long).

I need the macro to edit this variable by placing a space after the
4th, 8th and 12th number.

ie, from this: ################ to this: #### #### #### ####.

Is this possible?

Thanks,

Peter

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Adding spaces into a variable

Peter,

If you want to embed spaces, it can't go into a Long variable, it will have
to be a String.

With Me.TextBox1
sVar = Format(.text,"0000 0000 0000 0000"))
End With
--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Peter" wrote in message
ups.com...
I have a problem!

I am writing a macro where the user pastes in a 16 digit number into a
text box on a user form.
This then becomes a variable (long).

I need the macro to edit this variable by placing a space after the
4th, 8th and 12th number.

ie, from this: ################ to this: #### #### #### ####.

Is this possible?

Thanks,

Peter



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Adding spaces into a variable

Bob,

You are right, it is a string. Thanks for the code but it is still not
working. I am not sure what it is, can you help?

Thanks,

Peter

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Adding spaces into a variable

Is your textbox on a userform?

Describe how it is not working please.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Peter" wrote in message
oups.com...
Bob,

You are right, it is a string. Thanks for the code but it is still not
working. I am not sure what it is, can you help?

Thanks,

Peter



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Adding spaces into a variable

Thanks for your help, it works fine now.

The code helped a lot!

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
adding spaces John K Excel Discussion (Misc queries) 5 April 8th 10 03:49 PM
Adding Spaces to the end of a value JohnGuts Excel Worksheet Functions 4 July 30th 06 09:50 PM
Adding spaces to a cell catalfamo1220 Excel Discussion (Misc queries) 3 July 18th 06 04:03 PM
Remove spaces from a string variable blatham[_2_] Excel Programming 4 August 24th 05 11:29 AM
Remove spaces from a string variable T-®ex[_4_] Excel Programming 0 August 24th 05 09:25 AM


All times are GMT +1. The time now is 02:50 PM.

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

About Us

"It's about Microsoft Excel"