Como utilizar un código para registrar en una hoja, que me sirva para varias?
Tengo un código con el que registro en una hoja (Datos), pero me gustaría aprovechar el mismo código para 3 o 4 hojas más. ¿Cómo podría hacer?
Private Sub CommandButton1_Click()
Dim h1 As Worksheet, f As Long
If TextBox1 = "" Then Exit Sub
Set buscar = Sheets("Datos").Range("A:A").Find(TextBox1, LookIn:=xlValues, lookat:=xlWhole)
If Not buscar Is Nothing Then
MsgBox "Este código ya existe."
TextBox1 = "": TextBox1.SetFocus
Cancel = True
Else
Set h1 = Sheets("Datos")
f = h1.Range("A" & Rows.Count).End(3).Row + 1
h1.Cells(f, "A").Value = TextBox1.Value
h1.Cells(f, "B").Value = TextBox2.Value
MsgBox "Registro realizado con éxito"
End If
End Sub
1 respuesta
Respuesta de Dante Amor
1
