Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hidden Apostrophe

Status
Not open for further replies.

PWD

Technical User
Jul 12, 2002
823
0
0
GB
Good afternoon, we have data that comes from a 3rd party, attached, and there appears to be hidden apostrophes in the output. I just did a macro record to try to do a Text-to-Columns but, as you can see, the result is patchy. Can you suggest how to get rid of them before I run this simple code?

Many thanks.

Code:
Sub TextToColumns()
'
' TextToColumns Macro
'

Dim Counter As Integer
Dim MyString As String
Dim WS As Worksheet

    For Each WS In ActiveWorkbook.Worksheets
    
    With WS
    WSName = .Name
        .Activate
    End With
 
MyString = "IJK" 'define string
 
    For Counter = 1 To Len(MyString)
    
        x = Mid(MyString, Counter, 1)
        
        Columns(x & ":" & x).Select
        Selection.TextToColumns Destination:=Range(x & "1"), DataType:=xlFixedWidth, _
            FieldInfo:=Array(0, 1), TrailingMinusNumbers:=True
    
    Next Counter
  
Next WS

End Sub

Many thanks,
D€$
 
 https://files.engineering.com/getfile.aspx?folder=cc3800d6-9e94-49f0-80f3-057aa141d606&file=Copy_of_cwt_15_03_2019_15_59_28.xlsx
You may have a problem with proper conversion of date string to date. Input data has DMR order that is not recognised as date if first part is greater than 12. In text to columns set output column as date and select DMY order in input.

combo
 
Thanks, I just re-recorded it and have changed it to

Code:
FieldInfo:=Array(0, 4)

and that seems to have set these output columns, excepting the header row, to Date. Looks OK to me now! :)

Many thanks,
D€$
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top