hola he creado un a aplicacion y en uno de los modulos abre y cierra otro libro de excel dependiendo los cambios que se le hagan guarda y cierra pero al terminar de usar la aplicacion quedan muchas ventanas vacias abiertas tantas como capturas o modificaciones que hice
este es mi codigo
Private Sub MultiPage2_Click(ByVal Index As Long)
If MultiPage2.Value = 0 Then
Application.Visible = False
Application.ScreenUpdating = False
Workbooks.Open Filename:=ThisWorkbook.Path & "\" & "server.xlsx"
Worksheets("MATERIALES").Activate
Worksheets("MATERIALES").AutoFilter.Sort.SortFields.Clear
Worksheets("MATERIALES").AutoFilter.Sort.SortFields.Add Key:= _
Range("A1:A1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortTextAsNumbers
With Worksheets("MATERIALES").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("a1").Select
Set rngsource = Worksheets("MATERIALES").Range("a2:d1000")
With ListBox1
.List = rngsource.Cells.Value
End With
Windows("server.xlsx").Activate
ActiveWindow.Close savechanges:=False
Else
If MultiPage2.Value = 2 Then
Application.Visible = False
Application.ScreenUpdating = False
Workbooks.Open Filename:=ThisWorkbook.Path & "\" & "server.xlsx"
Worksheets("MATERIALES").Activate
Worksheets("MATERIALES").AutoFilter.Sort.SortFields.Clear
Worksheets("MATERIALES").AutoFilter.Sort.SortFields.Add Key:= _
Range("A1:A1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortTextAsNumbers
With Worksheets("MATERIALES").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("a1").Select
Set rngsource = Worksheets("MATERIALES").Range("a2:d1000")
With ListBox2
.List = rngsource.Cells.Value
End With
Windows("server.xlsx").Activate
hola he creado un a aplicacion y en uno de los modulos abre y cierra otro libro de excel dependiendo los cambios que se le hagan guarda y cierra pero al terminar de usar la aplicacion quedan muchas ventanas vacias abiertas tantas como capturas o modificaciones que hice
este es mi codigo
Private Sub MultiPage2_Click(ByVal Index As Long)
If MultiPage2.Value = 0 Then
Application.Visible = False
Application.ScreenUpdating = False
Workbooks.Open Filename:=ThisWorkbook.Path & "\" & "server.xlsx"
Worksheets("MATERIALES").Activate
Worksheets("MATERIALES").AutoFilter.Sort.SortFields.Clear
Worksheets("MATERIALES").AutoFilter.Sort.SortFields.Add Key:= _
Range("A1:A1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortTextAsNumbers
With Worksheets("MATERIALES").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("a1").Select
Set rngsource = Worksheets("MATERIALES").Range("a2:d1000")
With ListBox1
.List = rngsource.Cells.Value
End With
Windows("server.xlsx").Activate
ActiveWindow.Close savechanges:=False
Else
If MultiPage2.Value = 2 Then
Application.Visible = False
Application.ScreenUpdating = False
Workbooks.Open Filename:=ThisWorkbook.Path & "\" & "server.xlsx"
Worksheets("MATERIALES").Activate
Worksheets("MATERIALES").AutoFilter.Sort.SortFields.Clear
Worksheets("MATERIALES").AutoFilter.Sort.SortFields.Add Key:= _
Range("A1:A1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortTextAsNumbers
With Worksheets("MATERIALES").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("a1").Select
Set rngsource = Worksheets("MATERIALES").Range("a2:d1000")
With ListBox2
.List = rngsource.Cells.Value
End With
Windows("server.xlsx").Activate
ActiveWindow.Close savechanges:=False
End If
End If
Application.Visible = False
Application.ScreenUpdating = True
End Sub