Macro para copiar filas de datos encabezadas por su concepto de varias hojas e Excel de un libro i copiarlas en otro libro
Estoy intentando intentando crear un histórico a partir de varias hojas donde tengo datos de varias empresas por periodos,
Ej.
hoja 1= empresa 1 2015
hoja 2= empresa 1 2016
hoja 3= Empresa 2 2015
...
estos datos están clasificados por conceptos. Columna A
El caso es que necesito que estos datos se copien siguiendo el orden establecido de la página destino. Columna A
El programa que tengo hasta la fecha es el siguiente:
Sub ordenar_tarifas()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim Tar As Range
Dim col As Range
Dim ArchivoEntrada As String
Set l1 = ThisWorkbook
Set h1 = l1.Worksheets("Tarifas")
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Set Tar = Selection
ArchivoEntrada = "C:\Julen\Excel mesos empresas\Macro meses Empresa"
Set l2 = Workbooks.Open(ArchivoEntrada, True, True)
ws_count = l2.Sheets.Count
For i = 2 To Tar.Count + 1
For j = 2 To ws_count + 1
Set h2 = l2.Worksheets(j)
Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select
Set col = Selection
For k = 3 To col.Count + 2
If h1.Cells(i, 1) = h2.Cells(k, 1) Then
h2.Select
h2.Cells(k, 2).Select
h2.Range(Selection, Selection.End(xlToRight)).Copy
h1.Select
h1.Cells(i, 1).Select
h1.Range(Selection, Move.End(xlToRight)).Paste
End If
Next k
Next j
Next i
MsgBox ("Fin")
End Sub
Este siempre me esta dando errores de método select sin importar que haga.