I'm trying to get the last row in a single column, but I'm getting a Type Mismatch error at the line of code that say's arr = Join(arr, ",")
What am I doing wrong? For some reason this works when I specifically set the arr variable to Range("A1:A50"), but not when I try to dynamically find the last row.
Dim sFileName As String
Dim sDefaultPath As String
'Dim LastRow As Long
'Dim WS As Worksheet
sDefaultPath = Environ$("UserProfile") & "\My Documents\"
sFileName = "PhoneNumbers.txt"
Set WS = Worksheets("Sheet1")
LastRow = WS.Cells(WS.Rows.Count, "A").End(xlUp).Row
arr = WS.Cells(1, LastRow)
arr = Application.WorksheetFunction.Transpose(arr)
arr = Join(arr, ",")
FF = FreeFile()
Open sDefaultPath & sFileName For Output As #FF
Print #FF, arr
RetVal = Shell("Notepad.exe " & sDefaultPath & sFileName, 1)