The situation I am in is that I have a couple of .csv files with different names that follow the trend like kieranqueryone, kieranquerytwo and so on.
What I want to do is from a dashboard I have, at a click of a button it opens the fileopen dialog and let's me import these csv files to excel but for each file I open it puts it to a new tab with the csv file's name if that's possible at all?
I've searched the forum but cannot find anything like it, if someone could get me started or direct me to something I might have missed I would duely appreicate it.
where I am up to:
Private Sub Add_Multiple_Sheets_Click()
Application.DisplayAlerts = False
Dim SingleFile As Variant 'holds full path and filename
'Get filenames to open
SingleFile = Application.GetOpenFilename("Query Files (*.csv*),*csv", , "Select .csv Files...", , True)
'Exit procedure if user clicks cancel
If TypeName(SingleFile) = "Boolean" Then
Exit Sub
End If
Dim ifile As Integer 'file counter
ifile = 1
Do While ifile <= UBound(SingleFile)
'Open file
Dim myfile As String
Dim secAutomation As MsoAutomationSecurity
secAutomation = Application.AutomationSecurity
Application.AutomationSecurity = msoAutomationSecurityForceDisable
Workbooks.Open SingleFile(ifile)
Application.AutomationSecurity = secAutomation
myfile = ActiveWorkbook.Name
'Check file contains Course Booking sheet
Dim wsSheet As Worksheet
Dim CorrectType As Boolean
On Error Resume Next
For Each wsSheet In Worksheets
If wsSheet.Name = "KieranQueryOne" Then
CorrectType = True
End If
Next wsSheet
On Error GoTo 0
no idea if what I have so far will work, I've editted it slightly from when I imported excel sheets. but I need to say if wsSheet.Name = "KieranQueryOne" or "KieranQueryTwo" etc or a way around that so I can just import any file name then say put each csv files information to a new tab
Bookmarks