Descricao: |
Escola Saberexcel VBA Macros® - Treinamento com Macros, Fórmulas e Funções
 Estes macros e procedimentos do Aplicativo Microsoft Excel VBA(Visual Basic Application), decompoe números em linha, separados por espaços, usando o Evento de Planilha (Worksheets) SelectionChange(ao selecionar), decompõe os números nas células de colunas adjacentes. Espero que o exemplo possa lhe ser útil. Fique com Deus, Expedito Marcondes. '- - - - - - - - - - - - - - - - - - - - - - -'
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Target, Range("C:C")) Is Nothing Then On Error Resume Next If Target.Offset(0, -2) = "A Contabilizar" Then decompor_numeros End If End Sub
'- - - - - - - - - - - - - - - - - - - - - - -' Sub decompor_numeros() Selection.TextToColumns Destination:=ActiveCell, DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _ Semicolon:=False, Comma:=False, Space:=True, Other:=False, OtherChar _ :="(", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, _ 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1)), _ TrailingMinusNumbers:=True End Sub '- - - - - - - - - - - - - - - - - - - - - - -' Sub copiar() [b2].Select [a].Copy [b] 'aqui fiz uma copia a partir de um range nomeado.(duas planilhas) End Sub '- - - - - - - - - - - - - - - - - - - - - - -' 'Treinamentos Saberexcel(nao deixe de ler sobre nosso trabalho com as Instruções Loops) Sub Loop_I() Dim i As Integer For i = 1 To 8 If Cells(i, 1).Value = "A Contabilizar" Then Application.Run ("decompor_numeros") End If Next i End Sub '- - - - - - - - - - - - - - - - - - - - - - -' 'Treinamentos Saberexcel(nao deixe de ler sobre nosso trabalho com as Instruções Loops) Sub Loop_II() Dim i As Integer For i = 1 To 8 If Cells(i, 1).Value = "A Contabilizar" Then Cells(i, 1).Offset(0, 2).Select Application.Run ("decompor_numeros") End If Next i End Sub '- - - - - - - - - - - - - - - - - - - - - - -' 'nao deixe de ler sobre nosso trabalho (Tudo sobre Celulas e Range's) Sub Macro_I() 'treinamentos saberexcel Range("C3:C" & [C65536].End(xlUp).Row).TextToColumns Range("C3"), xlDelimited, , , , , , True End Sub '- - - - - - - - - - - - - - - - - - - - - - -'
 Aprenda tudo sobre planilhas do Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Escola Saberexcel VBA Estudos® - Treinamentos com Macros, Fórmulas e Funções.

|