VBA y hojas Excel
Nombre de la hoja (variable)
'asigna nombre variable a la hoja a variable
strHoja = ActiveWindow.Caption
Windows(strHoja).Activate 'para activar el libro del nombre asignado
strHoja = ActiveWindow.Caption
Windows(strHoja).Activate 'para activar el libro del nombre asignado
Insertar hoja nueva (elegir posición)
ActiveWorkbook.Sheets.Add Before:=Worksheets("Informe1")
Insertar hoja nueva (primera posición)
Sheets("Informe1").Copy After:=Worksheets(Worksheets.Count)
Mover hoja
Worksheets("informe5").Move After:=Worksheets("Informe4")
Ordenar hojas (orden alfabético)
intNumeroHojas = ActiveWorkbook.Worksheets.Count
For i = 1 To intNumeroHojas
For j = i To intNumeroHojas
If LCase(Worksheets(j).Name) <LCase(Worksheets(i).Name) Then
Worksheets(j).Move Before:=Worksheets(i)
End If
Next j
Next i
For i = 1 To intNumeroHojas
For j = i To intNumeroHojas
If LCase(Worksheets(j).Name) <LCase(Worksheets(i).Name) Then
Worksheets(j).Move Before:=Worksheets(i)
End If
Next j
Next i
Suprimir una hoja determinadaApplication.DisplayAlerts = FalseFor i = 1 To Sheets.Count
Sheets(i).Activate
xxx = ActiveCell.Worksheet.Name
If xxx = "Informe" Then
ActiveWindow.SelectedSheets.Delete
End If
Next
Application.DisplayAlerts = True
Application.DisplayAlerts = False
For i = 1 To Sheets.Count
Sheets(i).Activate
xxx = ActiveCell.Worksheet.Name
If xxx = "Informe" Then
ActiveWindow.SelectedSheets.Delete
End If
Next
Application.DisplayAlerts = True
Seleccionar primera hoja
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Seleccionar última hoja
ActiveWindow.ScrollWorkbookTabs Position:=xlLast


