+ Reply to Thread
Results 1 to 5 of 5

Trouble with a blank " " value as part of a VBA function

  1. #1
    Registered User
    Join Date
    06-26-2011
    Location
    Atlanta, GA
    MS-Off Ver
    MS365, vsn 16.0.17909.42302
    Posts
    45

    Trouble with a blank " " value as part of a VBA function

    I'm trying to use the REPT function in a macro, but I can't find a way to represent the " ". I've tried "" "" and "' '", but it generates an error every time.

    Yes, I do have valid values for the other variables. If I replace the " " with "0" for example, it runs fine and pads the string with zeroes. I need it to pad with blanks. I've highlighted the trouble area with red, I think.

    Range(NewColumnLetter & x).Value = "=" & "Rept(" & " " & "," & TotalCharacters & " - LEN(" & OldColumnLetter & x & "))&" & OldColumnLetter & x

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Trouble with a blank " " value as part of a VBA function

    hi,

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    09-23-2008
    Location
    Mexico
    Posts
    200

    Re: Trouble with a blank " " value as part of a VBA function

    Try Char(0)

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,050

    Re: Trouble with a blank " " value as part of a VBA function

    Actually, I think you need to use CHAR(32), not CHAR(0)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    06-26-2011
    Location
    Atlanta, GA
    MS-Off Ver
    MS365, vsn 16.0.17909.42302
    Posts
    45

    Re: Trouble with a blank " " value as part of a VBA function

    Maybe the CHAR options would work too, but """ """ worked perfectly. Probably the only combo I didn't try. Thanks.

+ 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. Replies: 2
    Last Post: 06-25-2013, 12:43 PM
  2. Trouble with "Excel 4.0 function stored in defined names" error
    By rkjudy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-20-2011, 01:54 PM
  3. Replies: 3
    Last Post: 02-16-2011, 02:55 PM
  4. Replies: 3
    Last Post: 08-28-2010, 09:31 AM
  5. Replies: 3
    Last Post: 12-14-2006, 01:36 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