Función buscarV que a la hora de encontrar el dato realñize una operación matemática
Por todo su profesionalismo impartido solicito una ayuda en una macro. Que haga la fun cion de BUSCARV con macros (que no deje la fórmula en la 1a celda) y que lo haga en toda la columna según referencia hacia la derecha quedando muy agradecido por su apoyo en aprender a programar siendo este mi primer lenguaje... Adjunto el código que tengo del botón
Private Sub CommandButton1_Click() Dim E, G, F, resul As Double Dim rango As Range Dim strDescripcion As String Dim ope As Variant On Error Resume Next 'If fila = Me.ListBox2.ListIndex Then 'Me.ListBox1.AddItem ListBox2.List(fila, 2) 'ListBox1.List(ListBox1.ListCount - 2, 2) = ListBox2.List(fila, 2) If ListBox2.ListCount > 0 Then Me.ListBox1.AddItem ListBox2.Text For i = 0 To ListBox2.ListCount - 1 If ListBox2.Selected(i) = True Then End If Next i End If With Application.WorksheetFunction strDescripcion = .VLookup(CDbl(Me.ListBox2.Value), Hoja2.Range("A:H"), 2, False) intCantidad = InputBox(strDescripcion & vbNewLine & vbNewLine & "Ingresa la cantidad.", "Cantidad", 1) End With ' Set rango = Sheets("Hoja2").Range("A1").CurrentRegion ' ope = Me.ListBox2.Value ' If IsNumeric(ope) Then ' ope = VBA.CDbl(ope) ' End If ' producto = Application.WorksheetFunction.VLookup(ope, rango, 2, 0) ' With Me ' .ListBox1.Value = producto For ope = 2 To strDescripcion E = Hoja2.Cells(ope, 5).Value G = Hoja2.Cells(ope, 7).Value F = Hoja2.Cells(ope, 6).Value resul = E * G / F ListBox1.List(ListBox1.ListCount - 1, 1) = resul Next ope End Sub
1 Respuesta
Respuesta de Dante Amor
1