I have excel files for 11 entities (countries).
I need to do adjustment sometimes on each of them or sometimes only chose which file should be adjusted.
I created checkboxes with labels:
Expand|Select|Wrap|Line Numbers
- x Select All
- x country1
- x country2
- ......
- ......
- x country11
Files names are the same as label captions connected with checkbox and ".xls" at the end.
Here is what I tried:
Expand|Select|Wrap|Line Numbers
- Dim LoopIndex As Integer
- Set xlapp = CreateObject("Excel.Application")
- xlapp.DisplayAlerts = False
- filepath = "path to the file"
- For LoopIndex = 1 To 11
- Select Case Me.Controls("CB" & LoopIndex)
- Case Me.Controls("CB" & LoopIndex) = True
- xlapp.workbooks.Open filepath & Me.Controls("LB" & LoopIndex).Caption & ".xls"
- xlapp.Visible = True
- xlapp.ActiveWorkbook.Save
- xlapp.ActiveWorkbook.Close
- Set xlapp = Nothing
- End Select
- Next LoopIndex