I am currently working on a code which should:
Read the item that the user selects from a Combobox, for example:
They are copied and, as I said, they are taken to the "EMPALMES" sheet and on that sheet the elements must be pasted from the cell B2 , in the following way :
I attached the code that I did to try to do all of the above, but the code does not work for me, I always get the error or the error 13 (the types do not match) or the 404 (An object is required)
Private Sub cmdagacc_Click()
Set h1 = Sheets("MEMORIAS ACTO") 'Origen
Set h2 = Sheets("EMPALMES") 'Destino
Set R1 = h1.Range("CJ29")
Set R2 = h1.Range("CJ87")
Evn = cbxtacc.Value
Dim rng As Range
If cbxtacc.Value = "" Or cbxtacc.ListIndex = -1 Then
MsgBox "Seleccione un tipo de Accesorio"
cbxtacc.SetFocus
Exit Sub
End If
Existe = False
Dim R As Object
Set b = h1.Range("CJ29:CK87").Find(Evn, LookIn:=xlValues, LookAt:=xlWhole)
If Not b Is Nothing Then
cl = b.Address
Do
Fila = b.Row + 1
k = 2
For j = Cells("CJ29").Cells To Columns("CK87").Column
If h1.Cells(Fila, j).Value = cbxtacc.Value Then
Existe = True
Fila = Fila + 1
k = k + 1
Do While h1.Cells(Fila, j).Value <> ""
h2.Cells(k, "B").Value = h1.Cells(Fila, j).Value
h2.Cells(k, "C").Value = h1.Cells(Fila, j + 1).Value
Fila = Fila + 1
k = k + 1
Loop
Exit For
End If
Next
Loop While Not b Is Nothing And b.Address <> cl
End If
If Existe = False Then
MsgBox "Error al agregar los Accesorios", vbExclamation
Else
MsgBox "Accesorios agregados", vbInformation
End If
Range("A1") = "Empalmes"
End Sub
I appreciate all the help you can give me, and I hope to see you succeed in explaining me clearly