Reputation: 577
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?
Upvotes: 1
Views: 319
Reputation: 54838
A5:C17
the formula =PSA(A5:C17)
processes the
non-empty cells in A5:A17
.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
Upvotes: 1
Reputation: 50007
If you want to add a quote to the beginning and end, try
=""""&E2&""""
Upvotes: 1