Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Public Sub createReport(book As Workbook, startRow As Long, folderPath As String)
- Dim outBook As Workbook
- Set outBook = Workbooks.Add
- Dim finalName As String
- Randomize
- finalName = "test" & Rnd & ".xls"
- outBook.SaveAs Filename:=folderPath & finalName
- outBook.Close
- End Sub
- Sub main()
- Application.ScreenUpdating = False
- Dim mainBook As Workbook
- Set mainBook = ThisWorkbook
- Dim folderPath As String
- 'folderPath = "C:\Users\Àäìèíèñòðàòîð\Desktop\Test"
- folderPath = mainBook.Worksheets("main").Cells(3, 1).Value & "\"
- Dim sourceFile As String
- 'sourceFile = "data.csv"
- sourceFile = mainBook.Worksheets("main").Cells(6, 1).Value
- If Dir(folderPath & sourceFile) = "" Then
- MsgBox ("Ôàéë " & folderPath & sourceFile & " íå íàéäåí!")
- Exit Sub
- End If
- Dim csvBook As Workbook
- Set csvBook = Workbooks.Open(Filename:=folderPath & sourceFile, Delimiter:=";", Local:=True)
- Dim startRow As Long
- startRow = 2
- Dim endRow As Long
- Do
- endRow = csvBook.Sheets(1).Cells(startRow, 2).End(xlDown).Row 'startRow + 6
- createReport csvBook, startRow, folderPath
- startRow = endRow + 3
- Loop While csvBook.Sheets(1).Cells(startRow, 1).Value <> ""
- csvBook.Close
- Application.ScreenUpdating = True
- End Sub
Add Comment
Please, Sign In to add comment