我有一个在linux上创建的文本文件,如果我在Word pad中打开它,文件会正常显示.但是当我在记事本中打开它时,当我尝试使用下面的代码将它加载到excel时,它显示为一行.
' Open the file
Open Filename For Input As #1
' Look for the Table Title
Do While Not (EOF(1) Or InStr(TextLine, TableTitle) > 0)
Line Input #1, TextLine
Loop
Run Code Online (Sandbox Code Playgroud)
如何将其拆分为原始行?有没有一个行结束分离器,vba可以使用?
我已经编写了这个函数来从字符串的开头和结尾删除空格,任何想法为什么它不起作用?
Public Function PrepareString(TextLine As String)
Do While Left(TextLine, 1) = " " ' Delete any excess spaces
TextLine = Right(TextLine, Len(TextLine) - 1)
Loop
Do While Right(TextLine, 1) = " " ' Delete any excess spaces
TextLine = Left(TextLine, Len(TextLine) - 1)
Loop
PrepareString = TextLine
End Function
Run Code Online (Sandbox Code Playgroud) 我要做的是在电子表格中选择一个表,然后根据2个不同的列进行排序
我用记录宏选项生成了这段代码.该表的大小发生了变化,这就是我使用xlDown的原因,不幸的是,代码后来引用了确切的单元格"B4:B52".知道如何解决这个问题吗?
Range("B4:J4").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range( _
"B4:B52"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range( _
"G4:G52"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("B4:J52")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Run Code Online (Sandbox Code Playgroud)