kal0123456789
New Member
- Joined
- Jan 4, 2022
- Messages
- 6
- Office Version
- 2010
- Platform
- Windows
I'm creating an app for user to select data but they don't have to select all the data. For example, they can choose to include some columns, but not the others. One thing that is known is the data selected will have the same rows(so if the user selects A1:A5 and C2:C5, then that's the user problem already). Then I want to join all the cells by the column for each row, hopping the cells that are not selected. I've seen the method in this forum, but I forgot the link(I'll add later if I can find it), so I just paste it down below. When I'm using this code, it fails because if the data selection is not contiguous. (I'm using Excel 2010 so cannot do TextJoin method)
My analysis of the code is because I don't understand what is the cell variable consist of in every loop, since it's not iterated from row1.Cells which can yield the cell's value by calling cell.value. Could you tell me what is inside the cell variable? And how do I apply with the selection method proposed by this link's answer?
VBA Code:
Dim rng As Range 'The range of selection
Dim row1 As Range, cell As Range
For Each row1 In rng.Rows
For Each cell In row1
Vlu = Join(Application.Index(cell.Resize(row1.row).value, 1, 0), "|")
Next cell
Next row1
My analysis of the code is because I don't understand what is the cell variable consist of in every loop, since it's not iterated from row1.Cells which can yield the cell's value by calling cell.value. Could you tell me what is inside the cell variable? And how do I apply with the selection method proposed by this link's answer?