Results 1 to 3 of 3

Thread: Spaces don't look like spaces?
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Oct 2007
    Posts
    233
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Spaces don't look like spaces?

    Hello,

    I am putting together a string, and using the print statement to output to a file.

    I have an equation in the cell that I want to print out. The equation results in a string. That string has general characters, and spaces in it, and looks fine in excel. I use the following to print to file, using VBA:

    theString = Cells(i, 6).Value
    myFile = "myfile.json"
    Open myFile For Output As #1
    Print #1 , Replace(theString, vbLf, vbCrLf)
    Close #1

    All the characters in the resulting string-in-file are OK, except the spaces. And only when I load the file into Visual Studio Code, which is a good json file editor. In another text editor, the spaces look like spaces.

    I cannot be sure I really have spaces where I should have spaces.

    Can you help?

  2. #2
    Board Regular
    Join Date
    Oct 2007
    Posts
    233
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Spaces don't look like spaces?

    I solved it. I cut and pasted spaces from another App where apparently they don't past into excel as actual spaces. I had to hand-type in all the spaces in the excel cells.

  3. #3
    Board Regular BlakeSkate's Avatar
    Join Date
    Jan 2015
    Location
    Pernsylvoonia
    Posts
    461
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Spaces don't look like spaces?

    could you not replace the special character space with a regular space instead of hand typing everything?
    vba syntax would be: replace(cell," " (special space), " ")
    or vice versa.

    might help you down the road if the problem occurs again
    -------------------------------------------------------------------------------
    I may not give the best VBA codes, but they sure are VBA codes.
    Help me help you by posting a snapshot of your data & your expected result
    Please use [ code][ /code] tags when posting VBA as well as proper indentation

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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