Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long
Sub Salvar()
'
' Salvar Macro
'
Application.ScreenUpdating = False
Sheets("1ª Nota").Visible = True
Sheets("2ª Nota").Visible = True
Sheets("3ª Nota").Visible = True
Sheets("4ª Nota").Visible = True
Sheets("5ª Nota").Visible = True
Sheets("6ª Nota").Visible = True
Sheets("7ª Nota").Visible = True
Sheets("8ª Nota").Visible = True
Sheets("9ª Nota").Visible = True
Sheets("10ª Nota").Visible = True
Sheets("11ª Nota").Visible = True
Sheets("12ª Nota").Visible = True
Sheets("13ª Nota").Visible = True
Sheets("14ª Nota").Visible = True
Sheets("15ª Nota").Visible = True
Sheets("16ª Nota").Visible = True
Sheets("17ª Nota").Visible = True
Sheets("18ª Nota").Visible = True
Sheets("19ª Nota").Visible = True
Sheets("20ª Nota").Visible = True
Sheets("21ª Nota").Visible = True
Sheets("22ª Nota").Visible = True
Sheets("23ª Nota").Visible = True
Sheets("24ª Nota").Visible = True
Sheets("25ª Nota").Visible = True
Sheets("Períodos").Visible = True
Sheets(Array("Resumen de NC", "1ª Nota", "2ª Nota", "3ª Nota", "4ª Nota", "5ª Nota", _
"6ª Nota", "7ª Nota", "8ª Nota", "9ª Nota", "10ª Nota", "11ª Nota", "12ª Nota", _
"13ª Nota", "14ª Nota", "15ª Nota", "16ª Nota", "17ª Nota", "18ª Nota", "19ª Nota", _
"20ª Nota", "21ª Nota", "22ª Nota", "23ª Nota", "24ª Nota")).Select
Sheets("Resumen de NC").Activate
Sheets("25ª Nota").Select Replace:=False
Sheets(Array("Resumen de NC", "1ª Nota", "2ª Nota", "3ª Nota", "4ª Nota", "5ª Nota", _
"6ª Nota", "7ª Nota", "8ª Nota", "9ª Nota", "10ª Nota", "11ª Nota", "12ª Nota", _
"13ª Nota", "14ª Nota", "15ª Nota", "16ª Nota", "17ª Nota", "18ª Nota", "19ª Nota", _
"20ª Nota", "21ª Nota", "22ª Nota", "23ª Nota", "25ª Nota")).Select
Sheets("25ª Nota").Activate
Sheets("24ª Nota").Select Replace:=False
Sheets(Array("Resumen de NC", "1ª Nota", "2ª Nota", "3ª Nota", "4ª Nota", "5ª Nota", _
"6ª Nota", "7ª Nota", "8ª Nota", "9ª Nota", "10ª Nota", "11ª Nota", "12ª Nota", _
"13ª Nota", "14ª Nota", "15ª Nota", "16ª Nota", "17ª Nota", "18ª Nota", "19ª Nota", _
"20ª Nota", "21ª Nota", "22ª Nota", "23ª Nota", "24ª Nota", "25ª Nota")).Copy
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Selection.Interior.ColorIndex = xlNone
Selection.Font.ColorIndex = 0
With Selection.Validation
.Delete
.Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
:=xlBetween
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
End With
Selection.FormatConditions.Delete
Range("K4").Select
ActiveCell.FormulaR1C1 = "Hoja Convertida a Solo Valores"
Range("K4").Select
ActiveCell.FormulaR1C1 = "Hoja Convertida a Sólo Valores"
Range("J4").Select
Sheets("1ª Nota").Select
If Sheets("Resumen de NC").Range("F6") = 0 Then
Application.DisplayAlerts = False
Worksheets("1ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F6") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("2ª Nota").Select
If Sheets("Resumen de NC").Range("F7") = 0 Then
Application.DisplayAlerts = False
Worksheets("2ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F7") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("3ª Nota").Select
If Sheets("Resumen de NC").Range("F8") = 0 Then
Application.DisplayAlerts = False
Worksheets("3ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F8") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("4ª Nota").Select
If Sheets("Resumen de NC").Range("F9") = 0 Then
Application.DisplayAlerts = False
Worksheets("4ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F9") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("5ª Nota").Select
If Sheets("Resumen de NC").Range("F10") = 0 Then
Application.DisplayAlerts = False
Worksheets("5ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F10") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("6ª Nota").Select
If Sheets("Resumen de NC").Range("F11") = 0 Then
Application.DisplayAlerts = False
Worksheets("6ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F11") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("7ª Nota").Select
Application.CutCopyMode = False
If Sheets("Resumen de NC").Range("F12") = 0 Then
Application.DisplayAlerts = False
Worksheets("7ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F12") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("8ª Nota").Select
If Sheets("Resumen de NC").Range("F13") = 0 Then
Application.DisplayAlerts = False
Worksheets("8ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F13") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("9ª Nota").Select
If Sheets("Resumen de NC").Range("F14") = 0 Then
Application.DisplayAlerts = False
Worksheets("9ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F14") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("10ª Nota").Select
If Sheets("Resumen de NC").Range("F15") = 0 Then
Application.DisplayAlerts = False
Worksheets("10ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F15") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("11ª Nota").Select
If Sheets("Resumen de NC").Range("F16") = 0 Then
Application.DisplayAlerts = False
Worksheets("11ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F16") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("12ª Nota").Select
If Sheets("Resumen de NC").Range("F17") = 0 Then
Application.DisplayAlerts = False
Worksheets("12ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F17") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("13ª Nota").Select
ActiveSheet.Unprotect
If Sheets("Resumen de NC").Range("F18") = 0 Then
Application.DisplayAlerts = False
Worksheets("13ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F18") <> 0 Then
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("14ª Nota").Select
If Sheets("Resumen de NC").Range("F19") = 0 Then
Application.DisplayAlerts = False
Worksheets("14ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F19") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("15ª Nota").Select
If Sheets("Resumen de NC").Range("F20") = 0 Then
Application.DisplayAlerts = False
Worksheets("15ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F20") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("16ª Nota").Select
If Sheets("Resumen de NC").Range("F21") = 0 Then
Application.DisplayAlerts = False
Worksheets("16ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F21") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("17ª Nota").Select
If Sheets("Resumen de NC").Range("F22") = 0 Then
Application.DisplayAlerts = False
Worksheets("17ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F22") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("18ª Nota").Select
If Sheets("Resumen de NC").Range("F23") = 0 Then
Application.DisplayAlerts = False
Worksheets("18ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F23") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("E14:F15").Select
End If
Sheets("19ª Nota").Select
If Sheets("Resumen de NC").Range("F24") = 0 Then
Application.DisplayAlerts = False
Worksheets("19ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F24") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("20ª Nota").Select
If Sheets("Resumen de NC").Range("F25") = 0 Then
Application.DisplayAlerts = False
Worksheets("20ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F25") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("21ª Nota").Select
If Sheets("Resumen de NC").Range("F26") = 0 Then
Application.DisplayAlerts = False
Worksheets("21ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F26") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("22ª Nota").Select
If Sheets("Resumen de NC").Range("F27") = 0 Then
Application.DisplayAlerts = False
Worksheets("22ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F27") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("23ª Nota").Select
If Sheets("Resumen de NC").Range("F28") = 0 Then
Application.DisplayAlerts = False
Worksheets("23ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F28") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("24ª Nota").Select
If Sheets("Resumen de NC").Range("F29") = 0 Then
Application.DisplayAlerts = False
Worksheets("24ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F29") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
Sheets("25ª Nota").Select
If Sheets("Resumen de NC").Range("F30") = 0 Then
Application.DisplayAlerts = False
Worksheets("25ª Nota").Delete
Application.DisplayAlerts = True
ElseIf Sheets("Resumen de NC").Range("F30") <> 0 Then
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("E14:F15").Select
Application.CutCopyMode = False
End If
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Resumen de NC").Select
ActiveSheet.Unprotect
If Sheets("Resumen de NC").Range("F7") = 0 Then
Range("AH7").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.EntireRow.Delete
Cells.Select
Selection.EntireRow.Hidden = False
Range("E3").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWorkbook.SaveAs Application.Substitute(Range("E3").Text, ":", "-")
ElseIf Sheets("Resumen de NC").Range("F7") <> 0 Then
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Range("C6").Select
Range("F6").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.EntireRow.Hidden = True
Range("AH30").Select
Range(Selection, Selection.End(xlUp)).Select
Selection.EntireRow.Delete
Cells.Select
Selection.EntireRow.Hidden = False
Range("C6").Select
Range("E3").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWorkbook.SaveAs Application.Substitute(Range("E3").Text, ":", "-")
Application.StatusBar = False
End If
Dim lpBuff As String * 25
Dim ret As Long, UserName As String
ret = GetUserName(lpBuff, 25)
UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
MsgBox UserName & vbCr & "Este libro será guardado en el archivo" & vbCr & "''Mis Documentos'' ó en ''c:\'' y con el nombre de:" & vbCr & vbCr & "''Preforma NC (''Fecha y Hora'') {Listado Anexo ''EXT''}''"
ActiveSheet.Shapes("Text Box 1").Select
Selection.Delete
Range("E3").Select
Selection.ClearContents
Range("AH6:AH30").Select
Selection.ClearContents
Range("U1:AE4").Select
Selection.ClearContents
Selection.ClearFormats
Range("C6").Select
Workbooks("Preforma NC (Anexo ''EXT'').xls").Close savechanges:=False
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub