1

I have a column in Excel with the following layout:

test.com
ba.com
test2.com

What i want to generate is a powershell array list so my result needs to be:

"test.com","ba.com", "test2.com"

I wanted to start by concattening my string at the start and end but can't seem to do this.

What i do is this in an empty column (E2 is value of my first site): ="""E2&"""

But the "-character doesn't seem to escape.

how to fix this?

0

3 Answers 3

2

You could use the ASCII code for a quote.

=CHAR(34)&E2&CHAR(34)
Sign up to request clarification or add additional context in comments.

Comments

1

If you want to add a quote to the beginning and end, try

=""""&E2&""""

Comments

1

'VBA PowerShell Array'

Highlights

  • Processes the first column only.
  • Ignores empty cells.
  • E.g. For the range A5:C17 the formula =PSA(A5:C17) processes the non-empty cells in A5:A17.

The Code

Function PSA(SourceRange As Range) As String
    ' Only for a one-column range

    Dim vnt As Variant    ' Source Range Array
    Dim strDel As String  ' PSA Delimiter
    Dim i As Long         ' Range Array Row Counter

    ' Copy first column of Source Range to Range Array.
    vnt = SourceRange(1, 1).Resize(SourceRange.Rows.Count)

    strDel = Chr(34) & "," & Chr(34)

    For i = 1 To UBound(vnt)
        If vnt(i, 1) <> "" Then
            If PSA <> "" Then
                PSA = PSA & strDel & vnt(i, 1)
              Else
                PSA = Chr(34) & vnt(i, 1)
            End If
        End If
    Next

    If PSA <> "" Then PSA = PSA & Chr(34)

End Function

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.