简体   繁体   中英

Excel-VBA - Format data in Column to Delimited

Need help making Col D "Delimited" from cell D2 to the last cell in Col D that is not blank. I used the Record Macro to try to just steal the code but it does not seem to be working. Can anybody explain how to edit this code so that it will work or provide a new code that does what I am asking.

Sub Delimit ()
Selection.TextToColumns Destination:=Columns("D"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
End Sub
Sub Delimit()
With Workbooks("Workbook Name")
    With .Sheets("Your Sheet Name Here")
       .Range("d2:" & .Range("d" & .Rows.Count).End(xlUp).Address).TextToColumns Destination:=.Range("D2"), DataType:=xlDelimited, _
         TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
         Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
         :=Array(1, 1), TrailingMinusNumbers:=True
    End With
End With
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM