Usuário com melhor resposta
Como separar o texto em linhas?

Pergunta
-
Gostaria de saber como separar um texto de uma célula em linhas.
Com o "split" faço isso em colunas, mas gostaria que fosse em linhas.
Exemplo
A1 =1,2,3,4,5,6 (Dentro de uma única célula)
Separado (Em linhas diferentes)
A1 = 1
A2 = 2
A3 = 3
A4 = 4
Respostas
-
Option Explicit Sub teste() Dim strTest As String Dim strArray() As String Dim intCount As Integer strTest = ThisWorkbook.Sheets("Planilha1").Range("A1").Value strArray = Split(strTest, ",") For intCount = LBound(strArray) To UBound(strArray) ThisWorkbook.Sheets("Planilha1").Range("A" & intCount + 1).Value = strArray(intCount) Next End Sub
Anderson Diniz
- Sugerido como Resposta AndersonFDiniz2 segunda-feira, 31 de julho de 2017 14:22
- Marcado como Resposta Rhuden Ramos segunda-feira, 31 de julho de 2017 14:42
-
Option Explicit Sub teste() Dim strTest As String Dim strArray() As String Dim intCount As Integer strTest = ThisWorkbook.Sheets("Planilha1").Range("A1").Value strArray = Split(strTest, ",") For intCount = LBound(strArray) To UBound(strArray) ThisWorkbook.Sheets("Planilha1").Range("E" & intCount + 2).Value = strArray(intCount) Next End Sub
Anderson Diniz
- Sugerido como Resposta AndersonFDiniz2 terça-feira, 1 de agosto de 2017 12:04
- Marcado como Resposta Rhuden Ramos terça-feira, 1 de agosto de 2017 12:05
-
Option Explicit Sub teste() Dim strTest As String Dim strArray() As String Dim intCount As Integer Dim linha, linha2 As Long For linha = 5 To 25 If InStr(1, ThisWorkbook.Sheets("Planilha1").Range("A" & linha).Value, ",") > 0 Then linha2 = linha strTest = ThisWorkbook.Sheets("Planilha1").Range("A" & linha2).Value strArray = Split(strTest, ",") For intCount = LBound(strArray) To UBound(strArray) ThisWorkbook.Sheets("Planilha1").Range("A" & intCount + 1+linha2).Value = strArray(intCount) Next End If Next linha End Sub
Anderson Diniz
- Sugerido como Resposta AndersonFDiniz2 quarta-feira, 4 de outubro de 2017 13:26
- Marcado como Resposta Rhuden Ramos quarta-feira, 4 de outubro de 2017 13:35
Todas as Respostas
-
Option Explicit Sub teste() Dim strTest As String Dim strArray() As String Dim intCount As Integer strTest = ThisWorkbook.Sheets("Planilha1").Range("A1").Value strArray = Split(strTest, ",") For intCount = LBound(strArray) To UBound(strArray) ThisWorkbook.Sheets("Planilha1").Range("A" & intCount + 1).Value = strArray(intCount) Next End Sub
Anderson Diniz
- Sugerido como Resposta AndersonFDiniz2 segunda-feira, 31 de julho de 2017 14:22
- Marcado como Resposta Rhuden Ramos segunda-feira, 31 de julho de 2017 14:42
-
Quando eu modifico a célula destino por exemplo: "A" para "E2" o código pula 20 linhas e inicia a separação no "E22"
For intCount = LBound(strArray) To UBound(strArray)
ThisWorkbook.Sheets("Plan1").Range("e2" & intCount + 1).Value = strArray(intCount)
NextGostaria que iniciasse na célula que indiquei não abaixo dela.
O código está funcionando como solicitado só tem este problema, sou novo em VBA então não consegui resolver.
Agradeço a ajuda.
-
-
Option Explicit Sub teste() Dim strTest As String Dim strArray() As String Dim intCount As Integer strTest = ThisWorkbook.Sheets("Planilha1").Range("A1").Value strArray = Split(strTest, ",") For intCount = LBound(strArray) To UBound(strArray) ThisWorkbook.Sheets("Planilha1").Range("E" & intCount + 2).Value = strArray(intCount) Next End Sub
Anderson Diniz
- Sugerido como Resposta AndersonFDiniz2 terça-feira, 1 de agosto de 2017 12:04
- Marcado como Resposta Rhuden Ramos terça-feira, 1 de agosto de 2017 12:05
-
-
Option Explicit Sub teste() Dim strTest As String Dim strArray() As String Dim intCount As Integer Dim linha, linha2 As Long For linha = 5 To 25 If InStr(1, ThisWorkbook.Sheets("Planilha1").Range("A" & linha).Value, ",") > 0 Then linha2 = linha Exit For End If Next linha strTest = ThisWorkbook.Sheets("Planilha1").Range("A" & linha2).Value strArray = Split(strTest, ",") For intCount = LBound(strArray) To UBound(strArray) ThisWorkbook.Sheets("Planilha1").Range("A" & intCount + 1).Value = strArray(intCount) Next End Sub
Anderson Diniz
- Sugerido como Resposta AndersonFDiniz2 sexta-feira, 29 de setembro de 2017 13:29
-
-
Option Explicit Sub teste() Dim strTest As String Dim strArray() As String Dim intCount As Integer Dim linha, linha2 As Long For linha = 5 To 25 If InStr(1, ThisWorkbook.Sheets("Planilha1").Range("A" & linha).Value, ",") > 0 Then linha2 = linha strTest = ThisWorkbook.Sheets("Planilha1").Range("A" & linha2).Value strArray = Split(strTest, ",") For intCount = LBound(strArray) To UBound(strArray) ThisWorkbook.Sheets("Planilha1").Range("A" & intCount + 1).Value = strArray(intCount) Next End If Next linha End Sub
Anderson Diniz
- Sugerido como Resposta AndersonFDiniz2 segunda-feira, 2 de outubro de 2017 14:37
-
Continua inserindo a partir da linha 5 e substituindo. Por Exemplo: tu separa os valores da célula A5 e eles vão ser postos na ordem correta seguindo para baixo, mas se tiver valores na célula A12 eles substituem os valores da A5 em vez de seguir a partir da célula A12.
- Editado Rhuden Ramos quarta-feira, 4 de outubro de 2017 13:08
-
Option Explicit Sub teste() Dim strTest As String Dim strArray() As String Dim intCount As Integer Dim linha, linha2 As Long For linha = 5 To 25 If InStr(1, ThisWorkbook.Sheets("Planilha1").Range("A" & linha).Value, ",") > 0 Then linha2 = linha strTest = ThisWorkbook.Sheets("Planilha1").Range("A" & linha2).Value strArray = Split(strTest, ",") For intCount = LBound(strArray) To UBound(strArray) ThisWorkbook.Sheets("Planilha1").Range("A" & intCount + 1+linha2).Value = strArray(intCount) Next End If Next linha End Sub
Anderson Diniz
- Sugerido como Resposta AndersonFDiniz2 quarta-feira, 4 de outubro de 2017 13:26
- Marcado como Resposta Rhuden Ramos quarta-feira, 4 de outubro de 2017 13:35
-