Insertar contenido de texbox a hoja copiada
Hola tengo este problema y espero puedas ayudarme,esta macro me guarda los datos del userform, al dar guardar se llama a otro userform3, el cual crea una copia de una hoja llamada "xxx", la pregunta seria como adaptar la macro para que me guarde en la en la copia de xxx el contenido del texbox4.
Macro para guardar contenido de userform 1
Private Sub CommandButton1_Click()
Dim i As Integer
Dim final As Integer
Dim shName As String
Dim A As Integer
Dim fin As Integer
If TextBox1 <> TextBox2 Then
UserForm2.Show
Exit Sub
End If
For i = 4 To 1000
If Hoja6.Cells(i, 2) = "" Then
final = i
Exit For
End If
Next
For A = 4 To 1000
If Hoja6.Cells(A, 1) = "" Then
fin = A
Exit For
End If
Next
Hoja6.Cells(fin, 1) = Hoja6.Cells(fin - 1, 1) + 1
Hoja6.Cells(final, 2) = UserForm1.TextBox2
Hoja6.Cells(final, 3) = UserForm1.TextBox4
Hoja6.Cells(final, 4) = UserForm1.TextBox3
If OptionButton1 = True Then
Hoja6.Cells(final, 6) = 0
End If
If OptionButton2 = True Then
Hoja6.Cells(final, 6) = 0.1
End If
If OptionButton3 = True Then
Hoja6.Cells(final, 6) = 0.15
End If
UserForm1.TextBox1 = ""
UserForm1.TextBox2 = ""
UserForm1.TextBox4 = ""
UserForm1.TextBox3 = ""
UserForm1.OptionButton1 = ""
UserForm1.OptionButton2 = ""
UserForm1.OptionButton3 = ""
UserForm1.Hide
UserForm3.Show
End Sub
Macro para crear una copia de xxx
Private Sub CommandButton1_Click()
Dim shName As String
If ActiveWorkbook Is Nothing Then Exit Sub
shName = Application.InputBox(prompt:="Nombre de la hoja?", Title:="Nombre", _
Type:=2)
Select Case shName
Case Is = "False"
MsgBox "No se ha insertado una hoja"
Exit Sub
Case Is = ""
Sheets("xxx").Add.coppy after:=Sheets(Sheets.Count)
Case Else
Sheets("xxx").Copy before:=Sheets(Sheets.Count)
ActiveSheet.Name = shName
End Select
UserForm3.Hide
End Sub
De antemano agradezco tu atencion prestada
Macro para guardar contenido de userform 1
Private Sub CommandButton1_Click()
Dim i As Integer
Dim final As Integer
Dim shName As String
Dim A As Integer
Dim fin As Integer
If TextBox1 <> TextBox2 Then
UserForm2.Show
Exit Sub
End If
For i = 4 To 1000
If Hoja6.Cells(i, 2) = "" Then
final = i
Exit For
End If
Next
For A = 4 To 1000
If Hoja6.Cells(A, 1) = "" Then
fin = A
Exit For
End If
Next
Hoja6.Cells(fin, 1) = Hoja6.Cells(fin - 1, 1) + 1
Hoja6.Cells(final, 2) = UserForm1.TextBox2
Hoja6.Cells(final, 3) = UserForm1.TextBox4
Hoja6.Cells(final, 4) = UserForm1.TextBox3
If OptionButton1 = True Then
Hoja6.Cells(final, 6) = 0
End If
If OptionButton2 = True Then
Hoja6.Cells(final, 6) = 0.1
End If
If OptionButton3 = True Then
Hoja6.Cells(final, 6) = 0.15
End If
UserForm1.TextBox1 = ""
UserForm1.TextBox2 = ""
UserForm1.TextBox4 = ""
UserForm1.TextBox3 = ""
UserForm1.OptionButton1 = ""
UserForm1.OptionButton2 = ""
UserForm1.OptionButton3 = ""
UserForm1.Hide
UserForm3.Show
End Sub
Macro para crear una copia de xxx
Private Sub CommandButton1_Click()
Dim shName As String
If ActiveWorkbook Is Nothing Then Exit Sub
shName = Application.InputBox(prompt:="Nombre de la hoja?", Title:="Nombre", _
Type:=2)
Select Case shName
Case Is = "False"
MsgBox "No se ha insertado una hoja"
Exit Sub
Case Is = ""
Sheets("xxx").Add.coppy after:=Sheets(Sheets.Count)
Case Else
Sheets("xxx").Copy before:=Sheets(Sheets.Count)
ActiveSheet.Name = shName
End Select
UserForm3.Hide
End Sub
De antemano agradezco tu atencion prestada
1 Respuesta
Respuesta de Roberto Alvarado
