Hi, how can I combine multiple rows of text into a single string without concatenating them on the sheet?
I'm trying to do something like this:
| |
| |
| |
|
I'm trying to do something like this:
VBA Code:
Sub Macro1()
Dim myWorkbook As Workbook
Dim mySheet As Worksheet
Dim lngRows As Long
Dim rngRows As Range
Dim mCode As String
Set myWorkbook = ThisWorkbook
Set mySheet = myWorkbook.Sheets("The Sheet Name")
lngRows = mySheet.Range("B1").Value 'Contains dynamic number of rows
Set rngRows = mySheet.Rows(1 & ":" & lngRows).Cells
mCode = rngRows.Value
myWorkbook.Queries.Item("Table Name").Formula = mCode
End Sub