+ Reply to Thread
Results 1 to 7 of 7

Spaces in string only visible in VBA

  1. #1
    Registered User
    Join Date
    08-05-2015
    Location
    Finland
    MS-Off Ver
    Home and Business 2013
    Posts
    50

    Spaces in string only visible in VBA

    Hello,

    So, in Excel normal view the cell seems to be normal and in the 'formula input box' the text is without any spaces (before text). But in VBA I go through every cell and giving that cell value to variable it gives the result
    " text text text". And that seems to be only one space. Trim and replace don't seem to work at all, so is there any other way to remove this invisible space?
    Original excel file is taken through Access from SQL server.
    Here the 'space' seems normal but in editing mode, it seems to be the length of 3-4 spaces.
    Last edited by The_Greg; 08-05-2015 at 03:50 AM. Reason: 'Space' view changed

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Spaces in string only visible in VBA

    You really need to determine what the character code is for that 'space'.

    you could try this in the immediate window. (ALT+F11 CTRL+G)

    Please Login or Register  to view this content.
    or in your code you could test the variable
    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    08-05-2015
    Location
    Finland
    MS-Off Ver
    Home and Business 2013
    Posts
    50

    Re: Spaces in string only visible in VBA

    Hi, I have never used immediate window, but msg ascw gives the value 9

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Spaces in string only visible in VBA

    9 denotes the characters is a TAB

  5. #5
    Registered User
    Join Date
    08-05-2015
    Location
    Finland
    MS-Off Ver
    Home and Business 2013
    Posts
    50

    Re: Spaces in string only visible in VBA

    Any idea why it is only visible in VBA code?

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Spaces in string only visible in VBA

    it's a print character.

    if you use the immediate window again but this time write to an empty cell
    Please Login or Register  to view this content.
    On the worksheet the space is not visible.
    Copy the cell to notepad and the tab will be replace with gap and the cursor will jump when you move along the text.
    Copy it to word and then display paragraph marks you will see a dot.

    Anyhoo what you need to do either remove the tab from the source tab or within your variable.

    for variable removal you can use
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-05-2015
    Location
    Finland
    MS-Off Ver
    Home and Business 2013
    Posts
    50

    Re: Spaces in string only visible in VBA

    Thank you very much, that worked!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Remove Spaces From Right End Of String
    By goss in forum Excel General
    Replies: 5
    Last Post: 05-05-2012, 04:52 AM
  2. [SOLVED] Remove Spaces from string
    By hecgroups in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-06-2012, 10:41 AM
  3. Take spaces out of a string
    By mizunobill in forum Excel General
    Replies: 1
    Last Post: 12-21-2010, 06:36 PM
  4. Remove the spaces in the last string
    By seanyeap in forum Excel General
    Replies: 3
    Last Post: 08-03-2010, 12:49 PM
  5. Adding spaces between certain text string
    By g_hadgraft in forum Excel General
    Replies: 1
    Last Post: 06-16-2009, 07:50 AM
  6. How to insert spaces in a string please
    By Andrew Thomas in forum Excel General
    Replies: 2
    Last Post: 07-17-2007, 08:49 AM
  7. Removing Spaces from string
    By katmando in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-16-2006, 09:16 AM
  8. Remove spaces from a string variable
    By blatham in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-24-2005, 07:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1