• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Please suggest a shorter way to delimit values

ThrottleWorks

Excel Ninja
Hi,

I am using below mentioned code to ‘delimit’ values.

This code is recorded. Could anyone please suggest me a shorter way to delimit the column.

Code:
Columns("A:A").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1), TrailingMinusNumbers:=True
 
Nothing wrong with that apart from applying it to the whole Column instead of just the data range

Code:
Dim rng As Range, lr As Integer
lr = Range("A" & Rows.Count).End(xlUp).Row
Set rng = Range("A1:A" & lr)
rng.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1), TrailingMinusNumbers:=True

You also don't need to define the parameters which are defualted
Code:
Dim rng As Range, lr As Integer
lr = Range("A" & Rows.Count).End(xlUp).Row
Set rng = Range("A1:A" & lr)
rng.TextToColumns Destination:=Range("A1"), _
  DataType:=xlDelimited, _
  TextQualifier:=xlDoubleQuote, _
  ConsecutiveDelimiter:=False, _
  Tab:=True, _
  FieldInfo:=Array(1, 1), _
  TrailingMinusNumbers:=True
 
Back
Top