forked from farishadi/Excel_Macro_References
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonModule
More file actions
38 lines (28 loc) · 930 Bytes
/
ButtonModule
File metadata and controls
38 lines (28 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'BUTTONS MODULE
'XBrowse variables
Public sFPth1 As String
Public wbX As Workbook
Public Sub XBrowse()
Application.ScreenUpdating = False
Set cmbBox = ThisWorkbook.Sheets("Macro").ComboBox1
'select and open X workbook
sFPth1 = Application.GetOpenFilename(, , "X File Workbook Selection")
If sFPth1 <> "" And sFPth1 <> "False" Then
'parse value into textbox
ThisWorkbook.Sheets("Macro").Range("C10").Value = sFPth1
'open workbook, get sheet names
Application.DisplayAlerts = False
Set wbX = Workbooks.Open(sFPth1)
Application.DisplayAlerts = True
cmbBox.Clear
'get each sheet name from workbook and place into combo box
For Each indSheet In wbX.Sheets
cmbBox.AddItem indSheet.Name
Next indSheet
wbX.Close savechanges:=False
Else
MsgBox "No file selected. Please re-run the macro and try again."
End
End If
Application.ScreenUpdating = False
End Sub