Ejecutar una Macro desde una formula

ximenab

New Member
Joined
Jan 17, 2013
Messages
1
Hola a todos, espero me puedan ayudar.

Tengo un archivo para mi empresa en el que calculo los tiempos dedicados a cada trabajo, identificados con un numero consecutivo de Orden de Trabajo. El archivo funciona de maravilla, pero ahora quiero que al "liquidar" (cambiar su estado de en proceso a finalizado) dicha orden no se me permita ingresar algún dato adicional a esa OT.

Mi idea, de ser posible, es crear una macro que, al figurar en la celda la palabra "LIQUIDADA" de alguna forma bloquee el ingreso de información en la celda de tiempo amenos que se cambie el numero de la OT.

Si se puede realizar? o mi idea es muy descabellada??. Agradezco enormemente a quien me pueda ayudar.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Primeramente, perdone me porque mi español no es muy bueno. Pero creo que por lo menos me puede entender.

Creo que la mejor opción cera atrancar las celdas y proteger la hoja. Primero, desatranque todas las celdas porque normalmente están atrancadas. Protege la hoja y escoge todas las opciones que dan. Luego, ponga este macro en la hoja:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)    
    If Not Intersect(Target, Range("G:G")) Is Nothing Then
        If Target = "LIQUIDADA" Then
            Me.Unprotect
            
            Range(Target.End(xlToLeft), Target.Offset(0, -1)).Locked = True
            
            Me.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
                False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
                AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows:=True, _
                AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, AllowDeletingRows:=True, _
                AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
        End If
    End If
End Sub

Este macro supone que la columna G es donde pondrá la palabra "LIQUIDADA" y que la otra información de la OT está a la izquierda. Cambie la parte que dice "G:G" a la columna correcta.
 
Last edited:
Upvote 0
Por favor usa este macro en vez de él que puse antes. Me olvide de hacer lo que desatranque las celdas cuando no halla la palabra “LIQUIDADO”.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("G:G")) Is Nothing Then
        Me.Unprotect
        Range(Target.End(xlToLeft), Target.Offset(0, -1)).Locked = (Target = "LIQUIDADA")
        Me.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
            False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
            AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows:=True, _
            AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, AllowDeletingRows:=True, _
            AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,548
Messages
6,125,464
Members
449,229
Latest member
doherty22

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top