I found a VBA script to convert a column of text to a single cell separated by spaces (see below), BUT it will only select a list of data from column A and only return the data to column B.
I was able to figure out that altering the numbers in rows 7 and 8 (dataRow =# and listRow =#) will change the row numbers.
I would like to be able to specify a cell number for both the row/column that the list is located as well as the output cell for the new single cell list.
Any ideas?
Please and thank you.
~ Ky
----------------------------------
Sub generatecsv()
Dim dataRow As Integer
Dim listRow As Integer
Dim data As String
dataRow = 1: Rem the row that it is being read from column A otherwise known as 1 in vb script
listRow = 1: Rem the row in column B that is getting written
Do Until Cells(dataRow, 1).Value = "" And Cells(dataRow + 1, 1).Value = ""
If (data = "") Then
data = Cells(dataRow, 1).Value
Else
If Cells(dataRow, 1).Value <> "" Then
data = data & " " & " " & Cells(dataRow, 1).Value
Else
Cells(listRow, 2).Value = data
data = ""
listRow = listRow + 1
End If
End If
dataRow = dataRow + 1
Loop
Cells(listRow, 2).Value = data
End Sub
I was able to figure out that altering the numbers in rows 7 and 8 (dataRow =# and listRow =#) will change the row numbers.
I would like to be able to specify a cell number for both the row/column that the list is located as well as the output cell for the new single cell list.
Any ideas?
Please and thank you.
~ Ky
----------------------------------
Sub generatecsv()
Dim dataRow As Integer
Dim listRow As Integer
Dim data As String
dataRow = 1: Rem the row that it is being read from column A otherwise known as 1 in vb script
listRow = 1: Rem the row in column B that is getting written
Do Until Cells(dataRow, 1).Value = "" And Cells(dataRow + 1, 1).Value = ""
If (data = "") Then
data = Cells(dataRow, 1).Value
Else
If Cells(dataRow, 1).Value <> "" Then
data = data & " " & " " & Cells(dataRow, 1).Value
Else
Cells(listRow, 2).Value = data
data = ""
listRow = listRow + 1
End If
End If
dataRow = dataRow + 1
Loop
Cells(listRow, 2).Value = data
End Sub