Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub записьлиставтекстфайл2()
  2.  
  3. Dim s As String
  4. book = "предл просн.xls"
  5. Workbooks(book).Activate
  6. sheet = Application.ActiveSheet.Name
  7.  
  8. Open "C:\Users\Admin\Desktop\mitino\exp\almos2.csv" For Output As #1 'replace to your path
  9. Open "C:\Users\Admin\Desktop\mitino\exp\price.csv" For Output As #2 'replace to your path
  10.  
  11. startBookIndex = Workbooks(book).Sheets("ALMOS2").Index
  12. endBookIndex = Workbooks(book).Sheets("ALMOS4").Index
  13. RowIndex = 1
  14. i = 1
  15.  
  16. While startBookIndex <= endBookIndex
  17. rowsCount = Workbooks(book).Worksheets(startBookIndex).UsedRange.Rows.count + 1
  18.     While i < rowsCount
  19.         s = Workbooks(book).Worksheets(startBookIndex).Cells(i, 1).Value & ";" _
  20.         & Workbooks(book).Worksheets(startBookIndex).Cells(i, 2).Value & ";" _
  21.         & Workbooks(book).Worksheets(startBookIndex).Cells(i, 3).Value & ";" _
  22.         & Workbooks(book).Worksheets(startBookIndex).Cells(i, 4).Value & ";"
  23.         Print #1, s
  24.             Print #2, s
  25.              If RowIndex > 99849 Then
  26.                 Close #2
  27.                 outputFileIndex = outputFileIndex + 1
  28.                 Open "C:\Users\Admin\Desktop\mitino\exp\sklad" & outputFileIndex & ".csv" For Output As #2 'replace to your path
  29.                RowIndex = 0
  30.             End If
  31.             i = i + 1
  32.             RowIndex = RowIndex + 1
  33.     Wend
  34.     i = 1
  35.     startBookIndex = startBookIndex + 1
  36. Wend
  37. Close #2
  38. Close #1
  39. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement