Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' want to get the filename of the csv file and paste it into current workbook
- ' Dim fso As New FileSystemObject
- ' Dim fileName As String
- ' fileName = fso.GetFileName(strFile)
- ' wb1("Main Page").Range("O26").Value = fileName
- Sub ImportData()
- Application.DisplayAlerts = False
- Dim wb1 As Workbook
- Dim wb2 As Workbook
- Dim Sheet As Worksheet
- Dim PasteStart As Range
- Set wb1 = ActiveWorkbook
- Set PasteStart = [RRimport!A1]
- FileToOpen = Application.GetOpenFilename _
- (Title:="Please choose a Raw Data CSV File to Import", _
- FileFilter:="Report Files *.csv (*.csv),")
- If FileToOpen = False Then
- MsgBox "No File Specified.", vbExclamation, "ERROR"
- Exit Sub
- Else
- Set wb2 = Workbooks.Open(fileName:=FileToOpen)
- For Each Sheet In wb2.Sheets
- With Sheet.UsedRange
- .Copy PasteStart
- Set PasteStart = PasteStart.Offset(.Rows.Count)
- End With
- Next Sheet
- End If
- wb2.Close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement