Visual Basic para Aplicaciones - Copiar datos a un libro con macro desde otros libros

Life is soft - evento anual de software empresarial
 
Vista:

Copiar datos a un libro con macro desde otros libros

Publicado por andresD (1 intervención) el 15/09/2018 08:30:13
Hola a todos.

Me gustaría hacer una macro que, pudiera copiar datos desde los diferentes libros abiertos en ese momento, en concreto desde el último libro activo antes de activar el libro en el que está la macro .

Ahora tengo una macro que solo copia los datos del libro precios

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Sub trasladafila()
 
Dim mintmaterial As Integer
Dim mintFilaBase As Integer
Dim mdblprecio As Double
Dim mdbldescuento As Double
Windows("Precios.xlsx").Activate
ActiveCell.Select
Selection.Copy
mdblprecio = Cells(ActiveCell.Row, 3)
mdbldescuento = Cells(ActiveCell.Row, 4)
mdblotros = Cells(ActiveCell.Row, 5)
ThisWorkbook.Activate
ActiveSheet.Select
mintFilaBase = ActiveCell.Row
' indicar la fila en la que empezamos a mirar si tiene datos
mintmaterial = 34
Do While Cells(mintmaterial, 4) <> ""
        mintmaterial = mintmaterial + 1
Loop
If mintmaterial < 102 Then
    Cells(mintmaterial, 4).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Cells(mintmaterial, 20) = mdblprecio
    Cells(mintmaterial, 23) = mdbldescuento
    Cells(mintFilaBase + 1, 2).Select
Else
    MsgBox ("TABLA COMPLETA")
End If
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder