SaberExcel o Site das Macros Macro do Aplicativo Microsoft Excel VBA, concatena valores da coluna(A) e Coluna(B) em uma terceira coluna(C). observe que usei a Função SET para referenciar (Setar) as Colunas
Option Explicit Option Base 1
Sub Concatena_dados_de_duas_colunas()
Dim vaColuna1 As Variant, vaColuna2 As Variant, vaDados() As Variant Dim wsPlan As Worksheet Dim rnColuna1 As Range, rnColuna2 As Range, rnDados As Range Dim iNumero As Long
Set wsPlan = Worksheets("Plan1") Set rnColuna1 = wsPlan.Range("A2", Range("A65536").End(xlUp)) Set rnColuna2 = wsPlan.Range("B2", Range("B65536").End(xlUp))
vaColuna1 = rnColuna1.Value vaColuna2 = rnColuna2.Value
ReDim vaDados(1 To UBound(vaColuna1))
For iNumero = 1 To UBound(vaColuna1) vaDados(iNumero) = vaColuna1(iNumero, 1) & " " & vaColuna2(iNumero, 1) Next iNumero
Set rnDados = wsPlan.Range("C2", Range("C" & UBound(vaColuna1) + 1)) rnDados.Value = Application.Transpose(vaDados)
End Sub
Sub limpar() Range("c1:C10").ClearContents End Sub
Aprenda sobre Aplicativo Microsoft Excel VBA SaberExcel
|