Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
Agregue Bloquear celdas / rangos a un código VBA existente para crear áreas editables y permitir que VBA se ejecute

No he usado VBA antes, así que soy realmente nuevo en esto :-) El siguiente es el código que estoy usando actualmente, y simplemente necesito bloquear todas las áreas de la hoja (sin usar el nombre de la hoja) además de A13: A377, B1, D3:D4, D13:D377, F13:I377. No puedo proteger la hoja porque el VBA no funcionará. Ayuda por favor...

 Private Sub Worksheet_Change(ByVal Target As Range) ' To allow multiple selections in a Drop Down List in Excel (without repetition) Dim Oldvalue As String Dim Newvalue As String Application.EnableEvents = True On Error GoTo Exitsub If Target.Column = 1 Then If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then GoTo Exitsub Else: If Target.Value = "" Then GoTo Exitsub Else Application.EnableEvents = False Newvalue = Target.Value Application.Undo Oldvalue = Target.Value If Oldvalue = "" Then Target.Value = Newvalue Else If InStr(1, Oldvalue, Newvalue) = 0 Then Target.Value = Oldvalue & " & " & Newvalue Else: Target.Value = Oldvalue End If End If End If End If Application.EnableEvents = True Exitsub: Application.EnableEvents = True End Sub
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

desbloquear celdas y proteger hoja

¡No veo ninguna relación entre tu descripción y el código que has compartido! A continuación encontrará una propuesta para desbloquear una unión de celdas y proteger la hoja (¡sin contraseña!)

 Option Explicit Sub UnlockCells_and_Protect() Dim actSheet As String actSheet = "Sheet2" ' choose whatever you need 'actSheet = ActiveSheet.Name 'actSheet = Sheets(3).Name 'actsheet = "SpecialSheet" Call UnprotectSheet(actSheet) Call LockAll(actSheet) Call UnlockRange(actSheet, "A13:A377,B1,D3:D4,D13:D377,F13:I377") Call ProtectSheet(actSheet) End Sub Sub UnlockRange(sheetName As String, RangeReference As String) With Sheets(sheetName).Range(RangeReference) .Locked = False .FormulaHidden = False 'you might want to mark the unlocked cells for debugging Sheets(sheetName).Range(RangeReference).Interior.Color = vbYellow End With End Sub Sub ProtectSheet(sheetName As String) Sheets(sheetName).Protect DrawingObjects:=True, Contents:=True, Scenarios:=True End Sub Sub ProtectActiveSheet() ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True End Sub Sub UnprotectSheet(sheetName As String) Sheets(sheetName).Unprotect End Sub Sub UnprotectActiveSheet() ActiveSheet.Unprotect End Sub Sub LockAll(sheetName As String) Sheets(sheetName).Cells.Locked = True Sheets(sheetName).Cells.FormulaHidden = False 'if you marked the unlocked cells yellow you change 'them back to white with lock/unlock all Sheets(sheetName).Cells.Interior.Color = vbWhite End Sub Sub UnlockAll(sheetName As String) Sheets(sheetName).Cells.Locked = False Sheets(sheetName).Selection.FormulaHidden = False 'if you marked the unlocked cells yellow you change 'them back to white with lock/unlock all Sheets(sheetName).Cells.Interior.Color = vbWhite End Sub
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda