Seleccionas entre dos productos iguales el de mayor fecha
publicado
Seleccionar entre dos productos iguales el de mayor fecha
la idea es la siguiente al seleccionar el producto en el macro me tome el precio del producto con la fecha mas actual osea el precio actualizado
Sub detecta_producto()
If CmBProductos.Value <> Empty Then Call calcula_importe Else End If
End Sub
Sub calcula_importe()
If txtCantidad.Value = Empty Or cmbClave.Value = Empty Then Else Importefi.Text = CCur(txtPrecio.Text) * CCur(txtCantidad.Text)
End If End Sub Sub busca_art_precio()
Private Sub cmbClave_Change() If Me.cmbClave.Value = "" Then Exit Sub Dim sUltimaCelda As String Me.txtDescripcion.Text = "" Me.txtPrecio.Text = "" If Me.cmbClave.ListCount > 1 Then sUltimaCelda = Range("d3").End(xlDown).Address Else sUltimaCelda = "d4" End If Range("d4:" & sUltimaCelda).Select Selection.Find(What:=Trim(Me.cmbClave.Text), After:=ActiveCell, LookIn:=xlValues _ , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False, SearchFormat:=False).Activate With Me .txtDescripcion.Text = ActiveCell.Previous.Value .txtPrecio.Text = ActiveCell.Next.Value End With calcula_importe End Sub
Private Sub lblDescr_Click()
End Sub
Private Sub txtCantidad_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) ' esto es para que el textbox solo acepte numeros If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0 End If End Sub
Private Sub txtCantidad_Change() calcula_importe End Sub
Private Sub UserForm_Activate() Dim sUltimaCelda As String Me.cmbClave.Clear Sheets("Hoja1").Activate If Trim(Range("d4").Value) = "" Then Exit Sub If Trim(Range("d5").Value) = "" Then Me.cmbClave.AddItem (Range("d4").Value) Exit Sub End If sUltimaCelda = Range("d3").End(xlDown).Address For Each f In Range("d4:" & sUltimaCelda).Cells Me.cmbClave.AddItem (f.Value) Next End Sub
Seleccionar entre dos productos iguales el de mayor fecha
la idea es la siguiente al seleccionar el producto en el macro me tome el precio del producto con la fecha mas actual osea el precio actualizado
gracias
prueba2.zip