我想消除精确范围 (G1) 并使此文本到列代码动态以将列值转换为日期

I want to eliminate exact range (G1) & make this Text to column code dynamic to convert column values to date

    ActiveCell.EntireColumn.Select
    Selection.TextToColumns Destination:=Range("G1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 4), TrailingMinusNumbers:=True
    Selection.NumberFormat = "dd-mmm-yy"

找到解决办法了,感谢支持,修改后的代码应该是

ActiveCell.EntireColumn.Select

Dim myRange As Range
Set myRange = Selection

myRange.TextToColumns Destination:=myRange, DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
    Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
    :=Array(1, 4), TrailingMinusNumbers:=True
Selection.NumberFormat = "dd-mmm-yy"