Home » excel » excel – VBA removes slashes

excel – VBA removes slashes

Posted by: admin April 23, 2020 Leave a comment

Questions:

I am new to VBA in excel. So, i create a string from multiple parts and output it in a cell on some sheet like this:

Sheets("Output").Cells(iRow, 1).Value = LArray(0) + "?" + adding + "/#" + LArrayNew(1)

I am expecting: text?text/#text
But result on excel sheet is: text?text#text

Where is the “/”?

How to&Answers:

Something like:

Sub dural()
    Dim LArray(0 To 1) As String
    Dim adding As String, LArrayNew(0 To 1) As String

    adding = "X"
    LArrayNew(1) = "New"
    LArray(0) = "0"
    iRow = 1

    Sheets("Output").Cells(iRow, 1).Value = LArray(0) & "?" & adding & "/#" & LArrayNew(1)
End Sub

will produce:

0?X/#New

Note the slash is there!

enter image description here