Currently using Excel 2010 in where I have a command button called 'OpenFile' placed on a worksheet. This is linked to a Module.
This allows the user to select/open a .csv file which then opens in a new workbook. Once the file is loaded into the new workbook a UserForm also loads onto the active new sheet.
The code below shows this:
What im trying to get working is add another command button underneath onto the same worksheet where the 'LoadFile' command button so if the user closes the UserForm this can be called from the original work book but only to open the UserForm.
Can this be done?
I assumed its something simple as:
Any help is much appreciated.
This allows the user to select/open a .csv file which then opens in a new workbook. Once the file is loaded into the new workbook a UserForm also loads onto the active new sheet.
The code below shows this:
Code:
Option Explicit
Sub opencsv()
' Declare variables.
Dim myFile As String
Dim FileName As Variant
Dim myUserForm As FSelectFilter
' Select CSV file.
' Open dialog box title.
' Add title to open file dialogue box " Select .csv file to import
myFile = "CSV Files (*.csv),*.csv"
'Title = "Select .CSV File to Import"
FileName = Application.GetOpenFilename(Title:="Select .csv File to Import")
' Select and open the dialog box.
' If no file selected open dialog box.
If FileName = False Then
MsgBox "No File Selected"
Exit Sub
End If
'Show userform on current sheet
Set myUserForm = New FSelectFilter
myUserForm.Show
'Change active sheet name
ActiveSheet.Name = "Sheet1"
End Sub
What im trying to get working is add another command button underneath onto the same worksheet where the 'LoadFile' command button so if the user closes the UserForm this can be called from the original work book but only to open the UserForm.
Can this be done?
I assumed its something simple as:
Code:
Private Sub CommandButton1_Click()
myUserForm.Show
End Sub
Any help is much appreciated.