Descontar cantidad de una base de datos desde otra hoja

Encontré esta macro en la web, antes de solicitarte la ayuda la he intentado adaptar a mis necesidades pero no consigo que funcione, espero me puedas ayudar con esta o otra macro que tu consideres se adapta a mis necesidades, te envío el archivo.

1 Respuesta

Respuesta
1

H o l a :

Envíame un corro nuevo con el archivo y las explicaciones con ejemplos.

Recuerda poner tu nombre de usuario en el asunto.

Sal u dos

H o l a:

Te anexo la macro

Sub ActualizarMateriales()
'Por.Dante Amor
    Set h = Sheets("Materiales")
    For i = 21 To 39
        If Cells(i, "C") <> "" Then
            If Cells(i, "G") = 0 Or Cells(i, "G") < 0 Or Not IsNumeric(Cells(i, "G")) Then
                MsgBox "Cantidad incorrecta", vbExclamation
                Cells(i, "G").Select
                Exit Sub
            End If
            '
            Set b = h.Columns("A").Find(Cells(i, "C"), lookat:=xlWhole)
            If b Is Nothing Then
                MsgBox "El material no existe. No se puede continuar", vbExclamation
                Cells(i, "C").Select
                Exit Sub
            Else
                stock = h.Cells(b.Row, "L")
                If stock < Cells(i, "G") Then
                    MsgBox "Existencia menor a la Cantidad solicitada", vbCritical
                    Cells(i, "G").Select
                    Exit Sub
                End If
            End If
        Else
            Exit For
        End If
    Next
    '
    For i = 21 To 39
        If Cells(i, "C") <> "" Then
            Set b = h.Columns("A").Find(Cells(i, "C"), lookat:=xlWhole)
            h.Cells(b.Row, "L") = h.Cells(b.Row, "L") - Cells(i, "G")
        End If
    Next
    MsgBox "Existencias actualizadas"
End Sub

' : )
'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias
' : )

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas