Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. Sub TextToColumns()
  2.  
  3. 'Deines Last Row
  4. Dim LastRow As Long
  5. LastRow = 1048576 'the last row possible in excel
  6. 'optional alternative **LastRow** Code
  7. 'Counts number of rows (counts from last row of Column A):
  8. 'Dim LastRow As Long
  9. 'LastRow = Cells(Rows.Count, "A").End(xlUp).Row
  10.  
  11. 'Counts number of Columns (my headers start in row 1)
  12. Dim LastColumn As Long
  13. LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
  14.  
  15. 'Loops Text to columns
  16. Dim StartingRow, StartingColumn As Long
  17. StartingRow = 1
  18.  
  19. For StartingColumn = 1 To LastColumn
  20. Range(Cells(StartingRow, StartingColumn), Cells(LastRow, StartingColumn)).Select
  21.  
  22. Selection.TextToColumns , DataType:=xlDelimited, _
  23. TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
  24. Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
  25. :=Array(1, 1), TrailingMinusNumbers:=True
  26.  
  27. Next
  28.  
  29. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement