Tim Hanson
Member
I have been trying to make a function for Text To Column such that I input its elements into a 2nd sub but I am just not getting how it all fit together
Thanks
Thanks
Code:
Sub Text ToColumn()
fTextToColumns "Question", "9", "I", "["
End Sub
Code:
Sub fTextToColumns(colHeader As String, InsCol As Long, Dest as String Delimiter As String)
Dim aCell As Range
Set aCell = Sheet1.Rows(1).Find(What:=colHeader, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
'~~> Set your sheet here
Sheets(3).Select
'~~> Set your columns here
Columns(InsCol).Insert
Columns(InsCol).Insert
'*************************************************
Columns(aCell, Cells(1, aCell.Column)).Select
'*************************************************
'~Set destination range here
Selection.TextToColumns Destination:=Range(Dest & 1), DataType:=xlDelimited, _
TextQualifier:=xlNone, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="Delimiter", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
'****************************************
Columns(aCell, Cells(1, aCell.Column)).Select.Delete
'****************************************
End Sub