Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. Sub colWidth()
  2. Dim widthArray() As String
  3. Dim myFile, textline As String
  4. Dim x, y As Integer
  5.  
  6.  
  7. 'example text file containing column widths
  8. myFile = "C:qqqqqqqqqwidths.txt"
  9.  
  10. 'loop through the file and store each column width in an array
  11. Open myFile For Input As #1
  12. x = 1
  13. Do Until EOF(1)
  14. Line Input #1, textline
  15. ReDim Preserve widthArray(1 To x)
  16. widthArray(x) = textline
  17. x = x + 1
  18. Loop
  19. Close #1
  20.  
  21. 'using the array of column widths to adjust columns
  22. For y = 1 To UBound(widthArray)
  23. Columns(y).ColumnWidth = Int(widthArray(y))
  24. Next y
  25. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement