I created the following macro:
Sub Extraer1()
'Definir origen y destino que utilizaremos
Dim OrigenHoja As Excel.Worksheet, _
DestinoHoja As Excel.Worksheet, _
OrigenCelda As Excel.Range, _
DestinoCelda As Excel.Range
'Definir las hojas origen y destino
Set OrigenHoja = Worksheets("Origen")
Set DestinoHoja = Worksheets("Destino")
'Definir las celdas origen y destino
Const celdaOrg = "A1"
Const celdaDst = "A1"
'Indicar los rangos origen y destino
Set OrigenCelda = OrigenHoja.Range(celdaOrg)
Set DestinoCelda = DestinoHoja.Range(celdaDst)
'Seleccionar los rangos
ActiveSheet.Unprotect
OrigenCelda.Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
'Pegar en destino
DestinoCelda.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End Sub
When I run it shows me the error '1004' at run time. Error in the Select method of the Range class.
Someone can tell me where the error is.
Thank you.