Como coloco codigos en un modulo
Tengo un archivo que debido a toda la programacion que le he colocado ha quedado muy pesado, quiero saber como puedo colocar cada operacion en un modulo diferente y que cuando yo haga el cambio el textbox o del combobox me traiga la operacion del modulo y asi poder quitarla del userform.
Por ejemplo tengo este codigo en un textbox y quiero colocarlo en un modulo pero cuando vuelva a configurar el textbox pues solamente seria colocarle la operacion de que llame al modulo.
Private Sub cod_ref_AfterUpdate()
Set h = Sheets("AAA")
Set b = h.Columns("A").Find(cod_ref)
ref_prod = ""
If Not b Is Nothing Then
ref_prod = h.Cells(b.Row, "B")
End If
codmp1 = ""
If Not b Is Nothing Then
codmp1 = h.Cells(b.Row, "D")
End If
codmp2 = ""
If Not b Is Nothing Then
codmp2 = h.Cells(b.Row, "E")
End If
codmp3 = ""
If Not b Is Nothing Then
codmp3 = h.Cells(b.Row, "F")
End If
codmp4 = ""
If Not b Is Nothing Then
codmp4 = h.Cells(b.Row, "G")
End If
codmp5 = ""
If Not b Is Nothing Then
codmp5 = h.Cells(b.Row, "H")
End If
codmp6 = ""
If Not b Is Nothing Then
codmp6 = h.Cells(b.Row, "I")
End If
codmp7 = ""
If Not b Is Nothing Then
codmp7 = h.Cells(b.Row, "J")
End If
codmp8 = ""
If Not b Is Nothing Then
codmp8 = h.Cells(b.Row, "K")
End If
codmp9 = ""
If Not b Is Nothing Then
codmp9 = h.Cells(b.Row, "L")
End If
codmp10 = ""
If Not b Is Nothing Then
codmp10 = h.Cells(b.Row, "M")
End If
codmp11 = ""
If Not b Is Nothing Then
codmp11 = h.Cells(b.Row, "N")
Else
MsgBox "EL CODIGO NO EXISTE", vbExclamation, "BUSCAR EN LA BASE"
cod_ref.SetFocus
End If
Set h = Sheets("MP")
Set b = h.Columns("A").Find(codmp1)
desmp1 = ""
If Not b Is Nothing Then
desmp1 = h.Cells(b.Row, "B")
End If
Set b = h.Columns("A").Find(codmp2)
desmp2 = ""
If Not b Is Nothing Then
desmp2 = h.Cells(b.Row, "B")
End If
Set b = h.Columns("A").Find(codmp3)
desmp3 = ""
If Not b Is Nothing Then
desmp3 = h.Cells(b.Row, "B")
End If
Set b = h.Columns("A").Find(codmp4)
desmp4 = ""
If Not b Is Nothing Then
desmp4 = h.Cells(b.Row, "B")
End If
Set b = h.Columns("A").Find(codmp5)
desmp5 = ""
If Not b Is Nothing Then
desmp5 = h.Cells(b.Row, "B")
End If
Set b = h.Columns("A").Find(codmp6)
desmp6 = ""
If Not b Is Nothing Then
desmp6 = h.Cells(b.Row, "B")
End If
Set b = h.Columns("A").Find(codmp7)
desmp7 = ""
If Not b Is Nothing Then
desmp7 = h.Cells(b.Row, "B")
End If
Set b = h.Columns("A").Find(codmp8)
desmp8 = ""
If Not b Is Nothing Then
desmp8 = h.Cells(b.Row, "B")
End If
Set b = h.Columns("A").Find(codmp9)
desmp9 = ""
If Not b Is Nothing Then
desmp9 = h.Cells(b.Row, "B")
End If
Set b = h.Columns("A").Find(codmp10)
desmp10 = ""
If Not b Is Nothing Then
desmp10 = h.Cells(b.Row, "B")
End If
Set b = h.Columns("A").Find(codmp11)
desmp11 = ""
If Not b Is Nothing Then
desmp11 = h.Cells(b.Row, "B")
End If
End Sub