Consulting

Results 1 to 3 of 3

Thread: Solved: Blank Null Space

  1. #1
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location

    Solved: Blank Null Space

    hi,

    i have a very odd question.
    i need to have a cell populated with only blank or null spaces based on a number in a different cell or based on the length of strings in another cell.

    for example, if cell H9 = "XXXX", then i need cell H12 = "4blankspaces";
    if cell I7 = 6, then i need cell I13 = "6blankspaces"
    (i don't want the literal 4blankspaces or 6blankspaces, just the blanks...
    i couldn't input H12 = " " or I13= " " with the correct spaces)

    is this possible?


    thanks
    zach

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Is this what you want#

    =REPT(" ",LEN(H9)-LEN(SUBSTITUTE(H9,"X","")))

    and

    =REPT(" ",I7)
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location
    hi bob,

    thanks for the very interesting formula. didn't realize that existed.

    i just came up with this
    [vba]Sub testspace()
    nbrspace = Range("h7")
    Range("h12").ClearContents
    Do
    mycell = Len(Range("h12"))
    If mycell <> nbrspace Then
    Range("h12") = Range("h12") + Chr(160)
    Else
    Exit Sub
    End If
    Loop Until mycell = nbrspace
    End Sub[/vba]

Posting Permissions

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