En Macro pasar a celda el formato del TextBox a la(s) celda(s)
Nuevamente molestando.
En 2 de las macros quiero que introduzca en la(s) celda(s) el mismo formato que acusa el TextBox (txtUbic) sin tener que dar formato personalizado a las celdas
Tal vez no quepan la smacros, al que respondas envío las demás faltantes
Private Sub cbtNueClien_Click()
On Error Resume Next
Dim fila As Integer
Set ws = ActiveSheet
If cboHojas.Value = "" Then
MsgBox "NO HA SELECCIONADO HOJA"
Exit Sub
Else
'Viene de la Function valida(wtext As MSForms.Control, num)
If MINCaracter(txtCod, "Cod/Producto", 10) = False Then Exit Sub ''AQUI 10 DIGITOS MINIMO
If Application.CountIf(ActiveSheet.Range("B2:B50000"), txtProd.Value) Then 'Busca en la columna A si existe el contacto
Rem Si existe la rutina llega solo al If mensage. si no existe, brinca después de Else para insertar los datos.
Mensage = MsgBox("El producto " & txtProd.Text & " ya existe." & vbCrLf & vbCrLf & _
"Puede escribir nuevo nombre y seguir, o en otro proceso editar datos", vbInformation + vbOKOnly, "CONTACTO EXISTENTE")
txtProd.Text = "" 'Si te dá mensage, Limpia el TextBox
If Mensage = vbOK Then Exit Sub 'Del mensage presionas OK y hasta el Exit Sub llega la rutina
Else
''''
'Inserta datos de nuevo cliente
With ws
fila = .Range("A2:A25000").Find(txtCod, lookat:=xlWhole).Row
If Err.Number = 91 Then
fila = .Range("b" & .Rows.Count).End(xlUp)(2).Row
Call ingresar_datos(fila)
Exit Sub
End If
Call ingresar_datos(fila)
End With
End If
End If
Buscar.Enabled = False
End Sub
MACRO INVOLUCRADA Call ingresar_datos(fila)
Sub ingresar_datos(fila As Integer, Optional OrdenarPor As String = "B") 'Ordena por la columna B
Set ws = ActiveSheet
Application.ScreenUpdating = False
With ws
.Cells(fila, 1) = txtCod
.Cells(fila, 2) = txtProd
.Cells(fila, 3) = txtProve
.Cells(fila, 4) = txtFactu
.Cells(fila, 5) = Format(DTPicker1, "mm/dd/yyyy") 'DTPicker1 en ves de txtFFact
' .Cells(fila, 5) = NumberFormat = "dd/mm/yyyy" 'dar formato a la celda
.Cells(fila, 6) = CDbl(txtUbic.Value)
.Cells(fila, 7) = txtObser
.Range("A2:G" & fila).Sort key1:=.Range(OrdenarPor & fila)
End With
Application.ScreenUpdating = True
'limpiar controles
Call Limpar(Me)
'carga ListBox
Call BuscaCambio
Call actualizar_lista
Call contador(Me)
Range(Cells(Selection.Row, 1), Cells(Selection.Row, 7)).Select
'Range("A2").Select
txtCod.SetFocus
End Sub
1 respuesta
Respuesta de Elsa Matilde
1
