I'll try to summarize what I'm trying to do:
I made a userform so that my user inserts data that will feed a table, it can put "n" information and the table will be formed according to the volume of data that it populates.
After that, when it finishes and clicks END, I want another userform to open the screen with a sentence concatenating the data that was inserted, following a predetermined logic.
For example, after the inputs the worksheet looks like this:
WhatIwantisformynextuserformtobringthefollowingconcatenated:
'Test'-x"1111 | 2 | 66", "2222 | 2 | 77", "3333 | 3.88", "4444 | 3 | 99" -n
The terms that I need to add with & I can, but I do not know how to concatenate in this way the values of each column following the sequence and stopping to the point where there is no more information in the worksheet.
Another detail would be to have this separation between, between each concatenated
The section where I want to put the command to concatenate this is here:
Private Sub sair_click()
Dim parse As String
parse = "concatenado"
Unload Me
code.console = parse
code.Show
End Sub
(after it clicks on the END button "exit" opens my userform "code" with the "parse" variable that should have this concatenated result.
After using the solution I replaced the "ShowWithMessage sub" for the call of my last Userform, because it met the demand demanded (my user is expected to copy the result to paste in another location). Perhaps it is some mistake that I made, to illustrate better, the expected sequence is as follows:
1st Userform: The user inserts the title, after clicking enter, another userform opens;
2ndUserform:Theuserentersthethreeinformationneededtopopulatethecolumnsofthetableasmanytimesasnecessary(byclickingEnteraftereachfill).WhenitfinishesitclicksFIMthatbringsthelastUserformwithatextboxcontainingtheconcatenatedresult.
InthisexampleIsimulatedthecasewhereonlyonelinewasinsertedbytheuser.
+---+------------------+----------------+-----------+||A|B|C|+---+------------------+----------------+-----------+|1|NomedaPlanilha|Teste'|||2|NodedaAula|TipodaTarefa|Agrupador||3|"1111| | 2| | 66" |
| | | | |
+---+------------------+----------------+-----------+
3rd Userform: As stated above, the final result of inserting only one complete row in the table is as follows:
Thescriptofthe"END" button is as follows, using the solution proposed in this topic:
Private Sub sair_click()
Dim parse As String
Dim ws As Worksheet
Dim UltimaLinhaPlanilha As Long, Linhas As Long, Colunas As Long
Set ws = ThisWorkbook.Sheets("ADAE")
UltimaLinhaPlanilha = ws.UsedRange.Rows.Count
parse = ws.Range("B1") & " -x "
For Linhas = 3 To UltimaLinhaPlanilha
For Colunas = 1 To 3
parse = parse & ws.Cells(Linhas, Colunas)
Next Colunas
If Linhas <> UltimaLinhaPlanilha Then parse = parse & ","
Next Linhas
parse = parse & " -n"
Unload Me
code.console = parse 'Aqui eu chamo o ultimo userform "code" com o que estará escrito dentro da caixa de texto "console" no caso a variável "parse"
code.Show
End Sub