+ Reply to Thread
Results 1 to 2 of 2

Dash or Hyphen Automatically Adds Space in VBA code

  1. #1
    Registered User
    Join Date
    04-13-2014
    Location
    Houston, TX
    MS-Off Ver
    excel 2010
    Posts
    1

    Dash or Hyphen Automatically Adds Space in VBA code

    Is there a way to not allow VBA from automatically putting space in between a hyphen within the code?

    For example:

    I want it to look like this (see red):

    .Cells(x, 1).Value = CStr(oUser.sAMAccountName) 'Replace(oUser.Name, "CN=", "")
    .Cells(x, 2).Value = oUser.givenName
    .Cells(x, 3).Value = oUser.SN
    .Cells(x, 4).Value = oUser.DisplayName
    .Cells(x, 5).Value = oUser.department
    .Cells(x, 6).Value = oUser.test-Address


    This is what it always turns out to be (see red):

    .Cells(x, 1).Value = CStr(oUser.sAMAccountName) 'Replace(oUser.Name, "CN=", "")
    .Cells(x, 2).Value = oUser.givenName
    .Cells(x, 3).Value = oUser.SN
    .Cells(x, 4).Value = oUser.DisplayName
    .Cells(x, 5).Value = oUser.department
    .Cells(x, 6).Value = oUser.test - Address

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Dash or Hyphen Automatically Adds Space in VBA code

    Hello noodle88,

    If the code is to compiled then the answer is no. VBA uses the space as a parsing delimiter. If the code is in a comment or between double quotes then yes you can run it together.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ 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. Space between text and dash
    By tantcu in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-04-2013, 01:36 PM
  2. Batch Change .JPG File name: space with a dash
    By vargs in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-27-2013, 02:17 AM
  3. [SOLVED] Macro / VBA to replace space between numbers with a hyphen
    By chicolocal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-03-2013, 03:59 PM
  4. Code to automatically insert space in a string
    By alis88 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-15-2012, 05:48 PM
  5. VBA code-file name replace dash with space
    By vargs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-28-2010, 03:22 PM

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