Copiar textbox en diferentes columnas según el combobox
Tengo un formulario en el cual tengo un combobox con tipo de moneda y un texbox donde pondré el monto, lo que quisiera hacer es copiar el textbox en diferentes columnas según el tipo demoneda
Hola tengo lo siguiente el combobox con tipo de moneda con los valores soles y dolares

lo que necesito es que al selccionar un tipo de moneda del combobox el monto ingresado en el textbox se copie en la columna que le corresponda, en caso sea soles en la columna I, y en caso sea dolares en la columna J

Aquí la macro
Private Sub CommandButton1_Click()
Dim i
Set h = Sheets("Hoja3")
Select Case ComboBox1.ListIndex
Case 0: col = "I"
Case 1: col = "J"
End Select
'
i = 6
Do While Cells(i, col) <> ""
i = i + 1
Loop
h.Cells(i, col) = Val(TextBox1.Text)
End SubPrivate Sub UserForm_Initialize() ComboBox1. AddItem "soles" ComboBox1. AddItem "dolares" End Sub
Macro actualizada, cambiar la valoración de esta respuesta
Private Sub CommandButton1_Click()
ult = Sheets("ON TRADE- MAYORISTAS FY20").Cells(Rows.Count, 6).End(xlUp).Row
If TextBox1 = "" Or TextBox2 = "" Or TextBox3 = "" Or TextBox4 = "" Or TextBox5 = "" Or ComboBox1 = "" Or ComboBox2 = "" Or ComboBox3 = "" Or ComboBox4 = "" Or ComboBox5 = "" Then
MsgBox "Escriba todos los datos"
Else
Select Case ComboBox4.ListIndex
Case 0: col = "I" ' soles
Case 1: col = "J" ' dolares
End Select
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 1) = TextBox1
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 2) = CDate(TextBox2)
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 3) = ComboBox1
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 4) = ComboBox2
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 5) = TextBox3
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 6) = ComboBox3
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 7) = TextBox4
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 8) = ComboBox4
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, col) = TextBox1 ' soles o dólares
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 11) = ComboBox5
x = ult + 1
rango = "A" & x & ":L" & x
Sheets("ON TRADE- MAYORISTAS FY20").Select
Range(rango).Select
MsgBox "Se ha escrito correctamente su registro"
response = MsgBox("¿Desea añadir otro registro?", _
vbYesNo)
If response = vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""
ComboBox4.Text = ""
ComboBox5.Text = ""
TextBox1.SetFocus
Else
Unload Me
UserForm1.Show
End If
amigo, disculpa nuevamente la molestia para agregarle el formato de moneda al momento de copiarlo a la celda correspondiente
Estuve investigando e hice los ajustes
Macro actualizada
Private Sub CommandButton1_Click()
ult = Sheets("ON TRADE- MAYORISTAS FY20").Cells(Rows.Count, 6).End(xlUp).Row
If TextBox1 = "" Or TextBox2 = "" Or TextBox3 = "" Or TextBox4 = "" Or TextBox5 = "" Or ComboBox1 = "" Or ComboBox2 = "" Or ComboBox3 = "" Or ComboBox4 = "" Or ComboBox5 = "" Then
MsgBox "Escriba todos los datos"
Else
Select Case ComboBox4.ListIndex
Case 0: col = "I" ' soles
Case 1: col = "J" ' dolares
End Select
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 1) = TextBox1
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 2) = CDate(TextBox2)
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 3) = ComboBox1
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 4) = ComboBox2
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 5) = TextBox3
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 6) = ComboBox3
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 7) = TextBox4
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 8) = ComboBox4
'
If col = "I" Then
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, col).NumberFormat = "$#,##0_);($#,##0)"
Else
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, col).NumberFormat = "[$$-en-US]#,##0.00"
End If
'
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, col) = Val(TextBox1.Text) ' soles o dólares
Sheets("ON TRADE- MAYORISTAS FY20").Cells(ult + 1, 11) = ComboBox5
x = ult + 1
rango = "A" & x & ":L" & x
Sheets("ON TRADE- MAYORISTAS FY20").Select
Range(rango).Select
MsgBox "Se ha escrito correctamente su registro"
response = MsgBox("¿Desea añadir otro registro?", _
vbYesNo)
If response = vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""
ComboBox4.Text = ""
ComboBox5.Text = ""
TextBox1.SetFocus
Else
Unload Me
UserForm1.Show
End If
Amigo quisiera que me apoyes nuevamente, tengo lo siguiente

Tengo el siguiente formulario, tengo un combobox y al cambiar el combobox se carguen los datos en los textbox resaltados delsde el texbox1 al textbox6, los datos están en la siguiente tabla, además de que los textbox se bloqueen para no modificar esos textbox a excepción del textbox 2 correspondiente a status

El textbox 7 correspondiente a la fecha de creación quisiera que al ingresarlo me arroje en el textbox8 la diferencia de días entre el text box1 y el textbox8
Adicional a ello al momento de seleccionar el botón actualizar la información de los textbox en las celdas correspondientes incluidos los datos del textbox 7 y textbox8 que se agregaran en las siguientes columnas

Espero me pueda ayudar
- Compartir respuesta